Minor Changes
-
Load includes only for the rows a windowed query or a
findOneshows. A live query with anorderBy, or afindOne, no longer evaluates the includes in its ownselect(a child query,toArray,materialize, orfindOne) for rows outside the rows it shows, whetherlimitandoffsetset the window orsetWindowmoves it. A late page now costs about the same as the first one. Withdistinct, the query no longer loads children for every source row. Awherethat names correlation values starts their child loads at once only when no enclosing query is windowed or afindOne, and either the query is neither windowed nor afindOne, or it is afindOnethat shows one row for one named correlation value, with nooffset, and offset 0 at start if a window was requested before start. Any other window orfindOne, including a window thatsetWindowrequests later, can drop those rows. Includes inherited from a subquery infrom, and includes passed intofn.select, still load for every row before the window. (#2156)setWindownow moves only the query's own window. A window inside afromsubquery, a joined subquery, or an include child no longer answers it, so a query that is neither windowed nor afindOnethrowsSetWindowRequiresOrderByError, and one that is neither windowed nor an orderedfindOnerejects offset moves.Breaking: a
findOnekeeps its compiled limit, 1 (or 0 for.limit(0).findOne()). An orderedfindOnehas a movable window:getWindow()returns{ offset, limit }with that limit, andsetWindowcan move its offset but now throws the newSetWindowFindOneLimitErrorfor any other limit; before,setWindow({ limit: 3 })made afindOneshow three rows. An unorderedfindOneis a fixed one-row result that accepts only its compiled limit at offset 0:getWindow()returns{ offset: 0, limit: 1 }, and a nonzero offset throwsSetWindowRequiresOrderByError, as.offset()withoutorderBydoes.
Patch Changes
- An ordered, limited live query over an on-demand source without an index no longer leaves its window short when a LEFT-joined filter removes rows from the loaded prefix. For example, an anti-join could show an empty window after a visible row was deleted. Such a plan now counts the rows its window still needs, and reads the full source when its prefix cannot fill the window. (#2132)