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

Commitfb4f5e5

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 parenta24cd4b commitfb4f5e5

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
@@ -893,8 +893,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
893893

894894
Assert(!BTScanPosIsValid(so->currPos));
895895

896-
pgstat_count_index_scan(rel);
897-
898896
/*
899897
* Examine the scan keys and eliminate any redundant keys; also mark the
900898
* keys that must be matched to continue the scan.
@@ -957,6 +955,12 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
957955
_bt_start_array_keys(scan,dir);
958956
}
959957

958+
/*
959+
* Count an indexscan for stats, now that we know that we'll call
960+
* _bt_search/_bt_endpoint below
961+
*/
962+
pgstat_count_index_scan(rel);
963+
960964
/*----------
961965
* Examine the scan keys to discover where we need to start the scan.
962966
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp