Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc00c54a

Browse files
Fix nbtree pgstats accounting with parallel scans.
Commit5bf748b, which enhanced nbtree ScalarArrayOp execution, madeparallel index scans work with the new design for arrays via explicitscheduling of primitive index scans. Under this scheme a parallel indexscan with array keys will perform the same number of index descents asan equivalent serial index scan (barring corner cases where anindividual parallel worker discovers that it can advance the scan'sarray keys without anybody needing to perform another descent of theindex to get to the relevant page on the leaf level).Despite all this, the pgstats accounting wasn't updated; it continued toincrement the total number of index scans for the rel once per _bt_firstcall, no matter the details. As a result, the number of (primitive)index scans could be over-counted during parallel scans.To fix, delay incrementing the count of index scans until after we'veestablished that another descent of the index (using either _bt_searchor _bt_endpoint) is required. That way pg_stat_user_tables.idx_scanalways advances in the same way, regardless of whether or not the scanmakes use of parallelism.Oversight in commit5bf748b, which enhanced nbtree ScalarArrayOpexecution.Author: Peter Geoghegan <pg@bowt.ie>Reviewed-By: Tomas Vondra <tomas@vondra.me>Discussion:https://postgr.es/m/CAH2-Wz=E7XrkvscBN0U6V81NK3Q-dQOmivvbEsjG-zwEfDdFpg@mail.gmail.comDiscussion:https://postgr.es/m/CAH2-WzkRqvaqR2CTNqTZP0z6FuL4-3ED6eQB0yx38XBNj1v-4Q@mail.gmail.comBackpatch: 17-, where nbtree SAOP execution was enhanced.
1 parentd35e293 commitc00c54a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎src/backend/access/nbtree/nbtsearch.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
896896

897897
Assert(!BTScanPosIsValid(so->currPos));
898898

899-
pgstat_count_index_scan(rel);
900-
901899
/*
902900
* Examine the scan keys and eliminate any redundant keys; also mark the
903901
* keys that must be matched to continue the scan.
@@ -960,6 +958,12 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
960958
_bt_start_array_keys(scan,dir);
961959
}
962960

961+
/*
962+
* Count an indexscan for stats, now that we know that we'll call
963+
* _bt_search/_bt_endpoint below
964+
*/
965+
pgstat_count_index_scan(rel);
966+
963967
/*----------
964968
* Examine the scan keys to discover where we need to start the scan.
965969
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp