diff options
author | David Rowley | 2024-01-31 04:22:02 +0000 |
---|---|---|
committer | David Rowley | 2024-01-31 04:22:02 +0000 |
commit | b588cad688823b1e996ce05af4d88a954c005a3a (patch) | |
tree | 41ec222b7f8ad9ca83b80bd9be18e8815608fc60 /src/test/regress/expected/select_distinct.out | |
parent | 3e91dba8b079c02dc5204108c7e797b402c75779 (diff) |
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
Diffstat (limited to 'src/test/regress/expected/select_distinct.out')
-rw-r--r-- | src/test/regress/expected/select_distinct.out | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out index 9d44ea8056d..1f72756ccb4 100644 --- a/src/test/regress/expected/select_distinct.out +++ b/src/test/regress/expected/select_distinct.out @@ -348,6 +348,26 @@ SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0; 0 | 1 | 2 | 3 (1 row) +SET parallel_setup_cost=0; +SET min_parallel_table_scan_size=0; +SET max_parallel_workers_per_gather=2; +-- Ensure we get a plan with a Limit 1 in both partial distinct and final +-- distinct +EXPLAIN (COSTS OFF) +SELECT DISTINCT four FROM tenk1 WHERE four = 10; + QUERY PLAN +---------------------------------------------- + Limit + -> Gather + Workers Planned: 2 + -> Limit + -> Parallel Seq Scan on tenk1 + Filter: (four = 10) +(6 rows) + +RESET max_parallel_workers_per_gather; +RESET min_parallel_table_scan_size; +RESET parallel_setup_cost; -- -- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its -- very own regression file. |