# Performance of Large SELECT

**URL:** https://forums.percona.com/t/performance-of-large-select/1579
**Category:** Other MySQL® Questions
**Created:** [December 12, 2010, 12:11pm UTC](https://forums.percona.com/t/performance-of-large-select/1579 "2010-12-12T12:11:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![petmal](https://avatars.discourse-cdn.com/v4/letter/p/2acd7d/32.png) [@petmal](https://forums.percona.com/u/petmal)
#### Post date: [December 12, 2010, 12:11pm UTC](https://forums.percona.com/t/performance-of-large-select/1579/1 "2010-12-12T12:11:26Z")

</div>

Hello.  
I have a database (MySQL 5.1 at Ubuntu 10.10) with some 15000 tables each with ~1 000 000 rows on average. Each table has 6 DOUBLE columns. The storage engine is MyISAM. I have a C++ application that loads the data one table at a time and performs some calculations.  
The way I retrieve the data from the database is simply by: SELECT \* FROM table ORDER BY timestamp; (timestamp is the first column (DOUBLE) marked as UNIQUE)  
By far most of the time is spent in loading and fetching. It takes ~15s to load and fetch all the rows in one table (tried with the native C API, C++ Connector and MySQL Query Browser).  
When I load the same dataset from disk (plain text file) using fstream the same operation takes only ~4s.

Is it possible for MySQL to get anywhere near this value?

Thanks.  
Petr

P.S. No optimisations (server/tables) attempted so far.  
P.S. Tables.pdf attached to this post contains some statistics from PROCEDURE ANALYSE.

---

<div class="post-metadata">

### Author: ![petmal](https://avatars.discourse-cdn.com/v4/letter/p/2acd7d/32.png) [@petmal](https://forums.percona.com/u/petmal)
#### Post date: [December 12, 2010, 5:33pm UTC](https://forums.percona.com/t/performance-of-large-select/1579/2 "2010-12-12T17:33:21Z")

</div>

One observation: when I SELECT only one field from the table, DB and filesystem perform equally well (FS is ~0.5s faster), when two fields are SELECTED the time doubles etc. It almost looks line DB reads field-by-field…

The text file is read line-by-line, each line is then split into fields and the fields are the pushed into vectors.

The database version does something like this:

MYSQL\_ROW row;mysql\_query(conn, “SELECT timestamp FROM raw.dv113 ORDER BY timestamp;”);MYSQL\_RES\* rows1 = mysql\_store\_result(conn);while ((row = mysql\_fetch\_row(rows1))) {vector v;v.push\_back(safeStrtod(row[0]));v.push\_back(safeStrtod(row[1]));v.push\_back(safeStrtod(row[2]));v.push\_back(safeStrtod(row[3]));v.push\_back(safeStrtod(row[4]));v.push\_back(safeStrtod(row[5]));}mysql\_free\_result(rows1);
