Re: Support tid range scan in parallel?
Cary Huang <cary.huang@highgo.ca>
From: Cary Huang <cary.huang@highgo.ca>
To: "David Rowley" <dgrowleyml@gmail.com>
Cc: "Junwang Zhao" <zhjwpku@gmail.com>, "Rafia Sabih" <rafia.pghackers@gmail.com>, "Pgsql Hackers" <pgsql-hackers@postgresql.org>
Date: 2025-08-29T17:32:20Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix possibly uninitialized HeapScanDesc.rs_startblock
- d167c19295da 19 (unreleased) landed
-
Add parallelism support for TID Range Scans
- 0ca3b16973a8 19 (unreleased) landed
-
Avoid repeating loads of frozen ID values.
- dd0183469bb7 17.0 cited
Attachments
- v10-0001-v10-parallel-tid-range-scan.patch (application/octet-stream)
> The workers are ending their scan early because > heap_getnextslot_tidrange() returns false on the first call from the > parallel worker. Hi David, thank you for the testing! Yes, the previous v9 patch missed setting node->trss_mintid and node->trss_maxtid, causing the parallel workers to exit early due to heap_getnextslot_tidrange() returning false. With the attached v10 patch, the parallel leader and workers now have to evaluate (TidRangeEval()) the given TID ranges and set them via ExecTidRangeScanInitializeDSM(), ExecTidRangeScanReInitializeDSM() and ExecTidRangeScanInitializeWorker(). To prevent the leader and the workers from calling heap_setscanlimits() and trying to set phs_startblock and phs_numblock concurrently in shared memory, I added a condition to only allow parallel leader to set them. Since node->trss_mintid and node->trss_maxtid reside in local memory, the workers still have to call heap_set_tidrange () to have them set to return correct scan results: # SET parallel_setup_cost TO 0; # SET parallel_tuple_cost TO 0; # select count(*) from test where ctid >= '(10,10)' and ctid <= '(10000,10)'; count --------- 1848151 (1 row) # SET max_parallel_workers_per_gather TO 0; =# select count(*) from test where ctid >= '(10,10)' and ctid <= '(10000,10)'; count --------- 1848151 (1 row) thank you again! Cary