Warm run. A has millions of records, B,C,D... are smaller (thousands)
SELECT ... FROM A LEFT OUTER JOIN B ... LIMIT 1000 OFFSET 0;
this returned in < 0.1 seconds
SELECT ... FROM A LEFT OUTER JOIN B ... LIMIT 1000 OFFSET 1000000;
while this returns in > 4 seconds
Assuming the ordering is by A's PK, and all the joins are correctly indexed, I would have assumed the 2 operations ought to have similar performance, but it seems like its O(N) according to the offset...
Shouldn't the query plan be to select the 1000 out of A first and then do the join? I compared a select of just A with the two different offsets, and the time difference is much less than 1 second, so that shouldn't explain the large difference in the time given the joins.
Is this a deficiency in mysql query plan optimizer?