<p>For our application, we keep large amounts of data indexed by three integer columns (source, type and time). Loading significant chunks of that data can take some time and we have implemented various measures to reduce the amount of data that has to be searched and loaded for larger queries, such as storing larger granularities for queries that don't require a high resolution (time-wise).</p>

<p>When searching for data in our backup archives, where the data is stored in bzipped text files, but has basically the same structure, I noticed that it is significantly faster to untar to stdout and pipe it through grep than to untar it to disk and grep the files. In fact, the untar-to-pipe was even noticeably faster than just grepping the uncompressed files (i. e. discounting the untar-to-disk).</p>

<p>This made me wonder if the performance impact of disk I/O is actually much heavier than I thought. So here's my question:</p>

<p><i>Do you think putting the data of multiple rows into a (compressed) blob field of a single row and search for single rows on the fly during extraction could be faster than searching for the same rows via the table index?</i></p>

<p>For example, instead of having this table</p>

<pre><code>CREATE TABLE data ( `source` INT, `type` INT, `timestamp` INT, `value` DOUBLE);
</code></pre>

<p>I would have</p>

<pre><code>CREATE TABLE quickdata ( `source` INT, `type` INT, `day` INT, `dayvalues` BLOB );
</code></pre>

<p>with approximately 100-300 rows in data for each row in quickdata and searching for the desired timestamps on the fly during decompression and decoding of the blob field.</p>

<p>Does this make sense to you? What parameters should I investigate? What strings might be attached? What DB features (any DBMS) exist to achieve similar effects?</p>

[{'answer_id': 26046, 'author': 'Jeff Atwood', 'author_id': 1, 'author_profile': 'https://Stackoverflow.com/users/1', 'pm_score': 3, 'selected': True, 'text': '<blockquote>\n  <p>This made me wonder if the performance impact of disk I/O is actually much heavier than I thought.</p>\n</blockquote>\n\n<p>Definitely. If you have to go to disk, the performance hit is many orders of magnitude greater than memory. This reminds me of the classic Jim Gray paper, <a href="http://research.microsoft.com/research/pubs/view.aspx?tr_id=655" rel="nofollow noreferrer">Distributed Computing Economics</a>:</p>\n\n<blockquote>\n  <p>Computing economics are changing. Today there is rough price parity between (1) one database access, (2) ten bytes of network traffic, (3) 100,000 instructions, (4) 10 bytes of disk storage, and (5) a megabyte of disk bandwidth. This has implications for how one structures Internet-scale distributed computing: one puts computing as close to the data as possible in order to avoid expensive network traffic. </p>\n</blockquote>\n\n<p>The question, then, is how much data do you have and how much memory can you afford?</p>\n\n<p>And if the database gets <em>really</em> big -- as in nobody could ever afford that much memory, even in 20 years -- you need clever distributed database systems like Google\'s <a href="http://research.google.com/archive/bigtable.html" rel="nofollow noreferrer">BigTable</a> or <a href="http://hadoop.apache.org/core/" rel="nofollow noreferrer">Hadoop</a>.</p>\n'}, {'answer_id': 26081, 'author': 'Matthew Schinckel', 'author_id': 188, 'author_profile': 'https://Stackoverflow.com/users/188', 'pm_score': 0, 'selected': False, 'text': '<p>I made a similar discovery when working within Python on a database: the cost of accessing a disk is very, very high.  It turned out to be much faster (ie nearly two orders of magnitude) to request a whole chunk of data and iterate through it in python than it was to create seven queries that were narrower.  (One per day in question for the data)</p>\n\n<p>It blew out even further when I was getting hourly data.  24x7 lots of queries it lots!</p>\n'}]
['https://Stackoverflow.com/questions/26021', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2077/']