Consider the "LIMIT 1" optimization with parallel DISTINCT

David Rowley <drowley@postgresql.org>

Commit: b588cad688823b1e996ce05af4d88a954c005a3a
Author: David Rowley <drowley@postgresql.org>
Date: 2024-01-31T04:22:02Z
Releases: 17.0
Consider the "LIMIT 1" optimization with parallel DISTINCT

Similar to what was done in 5543677ec for non-parallel DISTINCT, apply
the same optimization when the distinct_pathkeys are empty for the
partial paths too.

This can be faster than the non-parallel version when the first row
matching the WHERE clause of the query takes a while to find.  Parallel
workers could speed that process up considerably.

Author: Richard Guo
Reviewed-by: David Rowley
Discussion: https://postgr.es/m/CAMbWs49JC0qvfUbzs-TVzgMpSSBiMJ_6sN=BaA9iohBgYkr=LA@mail.gmail.com

Files

Discussion