Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
5.5.0
-
Triaged
-
Unknown
Description
For MIN aggregate without group by, N1QL sends Limit 1 queries in API2 e.g. if the aggregate is on the first column or aggregate on second column but first column has equality.
With API3, this optimization is no longer available.
Either:
1. Indexer can have the extra logic to determine when such optimizations can be applied
2. N1QL can call API2 in such cases with LIMIT 1 or API3 without pushing down group aggr.
Attachments
For Gerrit Dashboard: MB-27861 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
93349,4 | MB-27861: Optimize MIN, MAX aggregate without group by | unstable | indexing | Status: MERGED | +2 | +1 |
113913,2 | MB-29605: Optimize MIN aggregate without group by when KeyPos > 0 | unstable | indexing | Status: MERGED | +2 | +1 |
We use to do MIN/MAX use IndexScan2 with LIMIT 1 in following cases.
– MIN argument needs to be constant or leading key only
– Predicate on leading key should not include NULL/MISSING
This is tricky to do in query engine use API2. One thing we can do is COUNT/MIN/MAX/COUNT(DISTINCT) attempt do API2 always. If more than 1 spans API2 will not be used.
Keshav Murthy any comments.