/ Check-in [559733b0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:For queries with both ORDER BY and LIMIT, if the rows of the inner loop are emitted in ORDER BY order and the LIMIT has been reached, then optimize by exiting the inner loop and continuing with the next cycle of the first outer loop.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 559733b09e9630fac9d9318a7ecbaba9134e9160
User & Date: drh 2016-05-20 14:11:37
References
2018-09-08
03:22 New ticket [9936b2fa] Infinite loop due to the ORDER BY LIMIT optimization. (artifact: 9b89fdd3 user: drh)
2017-12-13
16:33 New ticket [123c9ba3] Incorrect result when an index is used for an ordered join. (artifact: da421d67 user: drh)
2016-10-12
14:00 New ticket [96c1454c] Incorrect result with ORDER BY DESC and LIMIT (again). (artifact: e3b3158e user: drh)
2016-09-07
00:42 New ticket [0c4df461] Incorrect result with ORDER BY DESC and LIMIT. (artifact: 51389ac4 user: drh)
Context
2016-05-20
14:54
Optimizations to link list merge sort code in vdbesort.c, pcache.c, and rowset.c. Resulting binaries are 10 bytes smaller and use 0.03% fewer CPU cycles. (check-in: 9033afbb user: drh tags: trunk)
14:11
For queries with both ORDER BY and LIMIT, if the rows of the inner loop are emitted in ORDER BY order and the LIMIT has been reached, then optimize by exiting the inner loop and continuing with the next cycle of the first outer loop. (check-in: 559733b0 user: drh tags: trunk)
13:44
Set the NULLEQ flag on the sequence counter comparison in the ORDER BY LIMIT optimization, to avoid coverage complaints about not testing the NULL case. (Closed-Leaf check-in: ed1b30dc user: drh tags: orderby-limit)
12:22
Autoconf configure.ac adjustment to try to get it to look for both editline and readline automatically. (check-in: 645bd696 user: drh tags: trunk)
Changes
Unified Diffs Side-by-Side Diffs Patch

Changes to src/select.c.

Changes to src/sqliteInt.h.

Changes to src/where.c.

Changes to src/whereInt.h.

Added test/limit2.test.