3 ms·
Exactly. So the workaround looks like: - Make one query with LIMIT of 5% - If it returns LIMIT rows, do a query with NOT INDEXED Which is surprising; why not
by manimino 4y ago
Exactly. So the workaround looks like:
- Make one query with LIMIT of 5%
- If it returns LIMIT rows, do a query with NOT INDEXED
Which is surprising; why not build that into the query planning / execution in the first place?
- dllthomas 4y agoThe workaround is to understand how the questions you're asking the database relate to the structure of your data. What you describe is a brute force way to acquire that understanding on the fly on arbitrary queries. It might sometimes be the best you can do, and then it might be worth it (benchmark!), but in quite a few cases it'll be quite a bit slower.
- manimino 4y agoThat's a great point. The LIMIT workaround takes no knowledge of the data distribution, but an optimizer could do much better with some statistics such as estimated percentiles.