From 11db439e8ab534850464933be224b14f498b1460 Mon Sep 17 00:00:00 2001 From: Andrei Martsinchyk Date: Tue, 28 Nov 2023 09:12:15 -0800 Subject: [PATCH] (split) [#18095] YSQL: Enable Postgres parallel query 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 --- expected/yb_pg_pg_hint_plan.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/expected/yb_pg_pg_hint_plan.out b/expected/yb_pg_pg_hint_plan.out index cf83c31f8926..b0585a3ac0ec 100644 --- a/expected/yb_pg_pg_hint_plan.out +++ b/expected/yb_pg_pg_hint_plan.out @@ -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: