I have a medium sized data set of about 4m rows.
Running my query:
SELECT id
, var1
, var2
FROM table1
WHERE date< "2019-10-29"
and date>="2018-10-29"
and company_id = 17
LIMIT 260;
returns 253 rows and takes duration = 0.171 / fetch = 15.22s.
But when I vary the query to limit 240 rows:
SELECT id
, var1
, var2
FROM table1
WHERE date< "2019-10-29"
and date>="2018-10-29"
and company_id = 17
LIMIT 240;
It only takes 0.25s/0.000s.
Why does the variation in limit drastically impact the fetch time?
- An additional variation is if I restrict the date range to return less rows, this strangely ups the fetch time again (perhaps because the number or rows is less than the limit?)