forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0fbceae
committed
Show index search count in EXPLAIN ANALYZE, take 2.
Expose the count of index searches/index descents in EXPLAIN ANALYZE'soutput for index scan/index-only scan/bitmap index scan nodes. Thisinformation is particularly useful with scans that use ScalarArrayOpquals, where the number of index searches can be unpredictable due toimplementation details that interact with physical index characteristics(at least with nbtree SAOP scans, since Postgres 17 commit5bf748b).The information shown also provides useful context when EXPLAIN ANALYZEruns a plan with an index scan node that successfully applied the skipscan optimization (set to be added to nbtree by an upcoming patch).The instrumentation works by teaching all index AMs to increment a newnsearches counter whenever a new index search begins. The counter isincremented at exactly the same point that index AMs already incrementthe pg_stat_*_indexes.idx_scan counter (we're counting the same event,but at the scan level rather than the relation level). Parallel querieshave workers copy their local counter struct into shared memory when anindex scan node ends -- even when it isn't a parallel aware scan node.An earlier version of this patch that only worked with parallel awarescans became commit5ead85f (though that was quickly reverted by commitd00107c following "debug_parallel_query=regress" buildfarm failures).Our approach doesn't match the approach used when tracking other indexscan related costs (e.g., "Rows Removed by Filter:"). It is comparableto the approach used in similar cases involving costs that are onlyreadily accessible inside an access method, not from the executor proper(e.g., "Heap Blocks:" output for a Bitmap Heap Scan, which was recentlyenhanced to show per-worker costs by commit5a1e6df, using essentiallythe same scheme as the one used here). It is necessary for index AMs tohave direct responsibility for maintaining the new counter, since thecounter might need to be incremented multiple times per amgettuple call(or per amgetbitmap call). But it is also necessary for the executorproper to manage the shared memory now used to transfer each worker'scounter struct to the leader.Author: Peter Geoghegan <pg@bowt.ie>Reviewed-By: Robert Haas <robertmhaas@gmail.com>Reviewed-By: Tomas Vondra <tomas@vondra.me>Reviewed-By: Masahiro Ikeda <ikedamsh@oss.nttdata.com>Reviewed-By: Matthias van de Meent <boekewurm+postgres@gmail.com>Discussion:https://postgr.es/m/CAH2-WzkRqvaqR2CTNqTZP0z6FuL4-3ED6eQB0yx38XBNj1v-4Q@mail.gmail.comDiscussion:https://postgr.es/m/CAH2-Wz=PKR6rB7qbx+Vnd7eqeB5VTcrW=iJvAsTsKbdG+kW_UA@mail.gmail.com1 parent12c5f79 commit0fbceae
File tree
37 files changed
+797
-98
lines changed- contrib/bloom
- doc/src/sgml
- ref
- src
- backend
- access
- brin
- gin
- gist
- hash
- heap
- index
- nbtree
- spgist
- commands
- executor
- utils/adt
- include
- access
- executor
- nodes
- test/regress
- expected
- sql
- tools/pgindent
37 files changed
+797
-98
lines changedLines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
116 | 116 |
| |
117 | 117 |
| |
118 | 118 |
| |
| 119 | + | |
| 120 | + | |
119 | 121 |
| |
120 | 122 |
| |
121 | 123 |
| |
|
Lines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
173 | 173 |
| |
174 | 174 |
| |
175 | 175 |
| |
| 176 | + | |
176 | 177 |
| |
177 | 178 |
| |
178 | 179 |
| |
179 |
| - | |
| 180 | + | |
180 | 181 |
| |
181 | 182 |
| |
182 | 183 |
| |
| |||
208 | 209 |
| |
209 | 210 |
| |
210 | 211 |
| |
| 212 | + | |
211 | 213 |
| |
212 | 214 |
| |
213 | 215 |
| |
| 216 | + | |
214 | 217 |
| |
215 | 218 |
| |
216 | 219 |
| |
217 |
| - | |
| 220 | + | |
218 | 221 |
| |
219 | 222 |
| |
220 | 223 |
| |
|
Lines changed: 22 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4234 | 4234 |
| |
4235 | 4235 |
| |
4236 | 4236 |
| |
4237 |
| - | |
4238 |
| - | |
4239 |
| - | |
4240 |
| - | |
4241 |
| - | |
4242 |
| - | |
| 4237 | + | |
| 4238 | + | |
4243 | 4239 |
| |
4244 | 4240 |
| |
4245 | 4241 |
| |
| 4242 | + | |
| 4243 | + | |
| 4244 | + | |
| 4245 | + | |
| 4246 | + | |
| 4247 | + | |
| 4248 | + | |
| 4249 | + | |
| 4250 | + | |
| 4251 | + | |
| 4252 | + | |
| 4253 | + | |
4246 | 4254 |
| |
| 4255 | + | |
| 4256 | + | |
| 4257 | + | |
| 4258 | + | |
| 4259 | + | |
| 4260 | + | |
| 4261 | + | |
| 4262 | + | |
4247 | 4263 |
| |
4248 | 4264 |
| |
4249 | 4265 |
| |
|
Lines changed: 60 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
729 | 729 |
| |
730 | 730 |
| |
731 | 731 |
| |
| 732 | + | |
732 | 733 |
| |
733 | 734 |
| |
734 | 735 |
| |
| 736 | + | |
735 | 737 |
| |
736 | 738 |
| |
737 | 739 |
| |
| |||
790 | 792 |
| |
791 | 793 |
| |
792 | 794 |
| |
| 795 | + | |
793 | 796 |
| |
794 | 797 |
| |
795 | 798 |
| |
| |||
805 | 808 |
| |
806 | 809 |
| |
807 | 810 |
| |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
808 | 863 |
| |
809 | 864 |
| |
810 | 865 |
| |
| |||
861 | 916 |
| |
862 | 917 |
| |
863 | 918 |
| |
| 919 | + | |
864 | 920 |
| |
865 | 921 |
| |
866 | 922 |
| |
| |||
894 | 950 |
| |
895 | 951 |
| |
896 | 952 |
| |
| 953 | + | |
897 | 954 |
| |
898 | 955 |
| |
| 956 | + | |
899 | 957 |
| |
900 | 958 |
| |
901 | 959 |
| |
| |||
923 | 981 |
| |
924 | 982 |
| |
925 | 983 |
| |
| 984 | + | |
926 | 985 |
| |
927 | 986 |
| |
928 | 987 |
| |
| |||
1061 | 1120 |
| |
1062 | 1121 |
| |
1063 | 1122 |
| |
| 1123 | + | |
1064 | 1124 |
| |
1065 | 1125 |
| |
1066 | 1126 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
506 | 506 |
| |
507 | 507 |
| |
508 | 508 |
| |
| 509 | + | |
509 | 510 |
| |
510 | 511 |
| |
511 | 512 |
| |
512 |
| - | |
| 513 | + | |
513 | 514 |
| |
514 | 515 |
| |
515 | 516 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1046 | 1046 |
| |
1047 | 1047 |
| |
1048 | 1048 |
| |
| 1049 | + | |
1049 | 1050 |
| |
1050 | 1051 |
| |
1051 | 1052 |
| |
| |||
1090 | 1091 |
| |
1091 | 1092 |
| |
1092 | 1093 |
| |
| 1094 | + | |
1093 | 1095 |
| |
1094 | 1096 |
| |
1095 | 1097 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
592 | 592 |
| |
593 | 593 |
| |
594 | 594 |
| |
| 595 | + | |
| 596 | + | |
595 | 597 |
| |
596 | 598 |
| |
597 | 599 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
442 | 442 |
| |
443 | 443 |
| |
444 | 444 |
| |
| 445 | + | |
| 446 | + | |
445 | 447 |
| |
446 | 448 |
| |
447 | 449 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
625 | 625 |
| |
626 | 626 |
| |
627 | 627 |
| |
| 628 | + | |
| 629 | + | |
628 | 630 |
| |
629 | 631 |
| |
630 | 632 |
| |
| |||
750 | 752 |
| |
751 | 753 |
| |
752 | 754 |
| |
| 755 | + | |
| 756 | + | |
753 | 757 |
| |
754 | 758 |
| |
755 | 759 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
298 | 298 |
| |
299 | 299 |
| |
300 | 300 |
| |
| 301 | + | |
| 302 | + | |
301 | 303 |
| |
302 | 304 |
| |
303 | 305 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
749 | 749 |
| |
750 | 750 |
| |
751 | 751 |
| |
752 |
| - | |
| 752 | + | |
753 | 753 |
| |
754 | 754 |
| |
755 | 755 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
119 | 119 |
| |
120 | 120 |
| |
121 | 121 |
| |
| 122 | + | |
122 | 123 |
| |
123 | 124 |
| |
124 | 125 |
| |
| |||
446 | 447 |
| |
447 | 448 |
| |
448 | 449 |
| |
449 |
| - | |
| 450 | + | |
450 | 451 |
| |
451 | 452 |
| |
452 | 453 |
| |
| |||
711 | 712 |
| |
712 | 713 |
| |
713 | 714 |
| |
714 |
| - | |
| 715 | + | |
715 | 716 |
| |
716 | 717 |
| |
717 | 718 |
| |
|
0 commit comments
Comments
(0)