Skip to content

Commit

Permalink
(split) [#18095] YSQL: Enable Postgres parallel query
Browse files Browse the repository at this point in the history
Summary:
Enable Postgres' parallel query feature and implement parallel scan of
YB tables in YBSeqScan, IndexScan, IndexOnlyScan nodes.

Feature is enabled in preview mode, that is, it is disabled by default, to enable:
```
set yb_parallel_range_rows  to 10000;
```
indicates the number of estimated rows per parallel worker. Smaller table scans are not parallelized, default 0 effectively disables the feature. The parameter defines minimum number of parallel workers, while `max_parallel_workers_per_gather` works as the maximum.
```
set yb_enable_base_scans_cost_model to true;
```
since parallel query cost improvements are factored in Yugabyte costing functions.
Also make sure the target tables are large and ANALYZE was done for them. Due to
planned  parallelization overhead optimizer selects parallel plan only if it thinks the
target table is large, default 1000 rows would not be sufficient.

The feature depends on the DocDB ability to return key ranges for
parallel scan implemented in D26978. Those key ranges are stored in the
shared memory buffer from where they are taken one at a time by the
parallel workers.

Transaction consistency between parallel workers is ensured by main
backend sharing its session and transaction context.
Jira: DB-7135

Test Plan:
ybd --java-test org.yb.pgsql.TestPgRegressParallel
ybd --cxx-test pggate_test_select --gtest_filter PggateTestSelect.TestSelectHashRanges
ybd --cxx-test pggate_test_select --gtest_filter PggateTestSelect.TestSelectScanRanges

Reviewers: sergei, timur, jason, pjain, tnayak

Reviewed By: pjain, tnayak

Subscribers: ybase, smishra, yql, bogdan

Differential Revision: https://phorge.dev.yugabyte.com/D28398
  • Loading branch information
andrei-mart committed Nov 29, 2023
1 parent e78484f commit 11db439
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion expected/yb_pg_pg_hint_plan.out
Original file line number Diff line number Diff line change
Expand Up @@ -4371,8 +4371,8 @@ MergeJoin(t1 t2)
Leading(t1 t2)
Set(random_page_cost 2.0)
Rows(t1 t2 +10)
not used hint:
Parallel(t1 8 hard)
not used hint:
duplication hint:
error hint:

Expand Down

0 comments on commit 11db439

Please sign in to comment.