Note that there are some explanatory texts on larger screens.

plurals
  1. POsame query, dramatic different performances on different data. MySQL
    primarykey
    data
    text
    <p>So, I have this huge database with 40 Millions entries.</p> <p>the query is a simple (a_view is a view!)</p> <pre><code>select * from a_view where id &gt; x LIMIT 10000 </code></pre> <p>this is the behavior I get: If x is a little number (int) the query is super fast. when x > 29 Millions the query starts to take minutes. if it is closer to 30 Millions it takes hours. and so on...</p> <p>why is that? what can I do to avoid this? </p> <p>I am using InnoDB as engine, tables have indexes.</p> <p>the value of the limit is a critical one, it affects performances. if it is small the query is always fast. but if x is close to 30Millions then I need to be very careful to set it not too big (less than 300 hundreds), and still it is quite slow, but doesn't take forever</p> <p>If you need more details, feel free to ask.</p> <p>EDIT: here is the explain</p> <pre> +----+-------------+-------+--------+-----------------+---------+---------+---------------------+---------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+--------+-----------------+---------+---------+---------------------+---------+-------------+ | 1 | SIMPLE | aH | index | PRIMARY | PRIMARY | 39 | NULL | 3028439 | Using index | | 1 | SIMPLE | a | eq_ref | PRIMARY | PRIMARY | 4 | odb.aH.albumID | 1 | Using where | | 1 | SIMPLE | aHT | ref | PRIMARY,albumID | albumID | 4 | odb.a.albumID | 4 | | | 1 | SIMPLE | t | eq_ref | PRIMARY | PRIMARY | 4 | odb.aHT.id | 1 | Using where | | 1 | SIMPLE | g | eq_ref | PRIMARY | PRIMARY | 4 | odb.t.genre | 1 | | | 1 | SIMPLE | ar | eq_ref | PRIMARY | PRIMARY | 4 | odb.t.artist | 1 | | +----+-------------+-------+--------+-----------------+---------+---------+---------------------+---------+-------------+ </pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload