Comment 2 for bug 1710943

Revision history for this message
Mike Rylander (mrylander) wrote :

Just as a potential implementation note, it's possible to use a CTE for the main search and then select from the CTE twice, once to get the "window" of results based on limit/offset, and a second time to get the count. I used this technique in the "eliminate staged search" branch, and it works well. It's not free, but cost effective because non-recursive CTEs are only executed once in a query plan.

https://www.postgresql.org/docs/current/static/queries-with.html (search down for "a useful property")