@@ -729,11 +729,9 @@ WHERE t1.unique1 < 10 AND t1.unique2 = t2.unique2;
729
729
Buffers: shared hit=3 read=5 written=4
730
730
-> Bitmap Index Scan on tenk1_unique1 (cost=0.00..4.36 rows=10 width=0) (actual time=0.004..0.004 rows=10.00 loops=1)
731
731
Index Cond: (unique1 < 10)
732
- Index Searches: 1
733
732
Buffers: shared hit=2
734
733
-> Index Scan using tenk2_unique2 on tenk2 t2 (cost=0.29..7.90 rows=1 width=244) (actual time=0.003..0.003 rows=1 loops=10)
735
734
Index Cond: (unique2 = t1.unique2)
736
- Index Searches: 10
737
735
Buffers: shared hit=24 read=6
738
736
Planning:
739
737
Buffers: shared hit=15 dirtied=9
@@ -792,7 +790,6 @@ WHERE t1.unique1 < 100 AND t1.unique2 = t2.unique2 ORDER BY t1.fivethous;
792
790
Buffers: shared hit=92
793
791
-> Bitmap Index Scan on tenk1_unique1 (cost=0.00..5.04 rows=100 width=0) (actual time=0.013..0.013 rows=100.00 loops=1)
794
792
Index Cond: (unique1 < 100)
795
- Index Searches: 1
796
793
Buffers: shared hit=2
797
794
Planning:
798
795
Buffers: shared hit=12
@@ -808,58 +805,6 @@ WHERE t1.unique1 < 100 AND t1.unique2 = t2.unique2 ORDER BY t1.fivethous;
808
805
shown.)
809
806
</para>
810
807
811
- <para>
812
- Index Scan nodes (as well as Bitmap Index Scan and Index-Only Scan nodes)
813
- show an <quote>Index Searches</quote> line that reports the total number
814
- of searches across <emphasis>all</emphasis> node
815
- executions/<literal>loops</literal>:
816
-
817
- <screen>
818
- EXPLAIN ANALYZE SELECT * FROM tenk1 WHERE thousand IN (1, 500, 700, 999);
819
- QUERY PLAN
820
- -------------------------------------------------------------------&zwsp;---------------------------------------------------------
821
- Bitmap Heap Scan on tenk1 (cost=9.45..73.44 rows=40 width=244) (actual time=0.012..0.028 rows=40.00 loops=1)
822
- Recheck Cond: (thousand = ANY ('{1,500,700,999}'::integer[]))
823
- Heap Blocks: exact=39
824
- Buffers: shared hit=47
825
- -> Bitmap Index Scan on tenk1_thous_tenthous (cost=0.00..9.44 rows=40 width=0) (actual time=0.009..0.009 rows=40.00 loops=1)
826
- Index Cond: (thousand = ANY ('{1,500,700,999}'::integer[]))
827
- Index Searches: 4
828
- Buffers: shared hit=8
829
- Planning Time: 0.037 ms
830
- Execution Time: 0.034 ms
831
- </screen>
832
-
833
- Here we see a Bitmap Index Scan node that needed 4 separate index
834
- searches. The scan had to search the index from the
835
- <structname>tenk1_thous_tenthous</structname> index root page once per
836
- <type>integer</type> value from the predicate's <literal>IN</literal>
837
- construct. However, the number of index searches often won't have such a
838
- simple correspondence to the query predicate:
839
-
840
- <screen>
841
- EXPLAIN ANALYZE SELECT * FROM tenk1 WHERE thousand IN (1, 2, 3, 4);
842
- QUERY PLAN
843
- ----------------------------------------------------------------------------------------------------------------------------------
844
- Bitmap Heap Scan on tenk1 (cost=9.45..73.44 rows=40 width=244) (actual time=0.009..0.019 rows=40.00 loops=1)
845
- Recheck Cond: (thousand = ANY ('{1,2,3,4}'::integer[]))
846
- Heap Blocks: exact=38
847
- Buffers: shared hit=40
848
- -> Bitmap Index Scan on tenk1_thous_tenthous (cost=0.00..9.44 rows=40 width=0) (actual time=0.005..0.005 rows=40.00 loops=1)
849
- Index Cond: (thousand = ANY ('{1,2,3,4}'::integer[]))
850
- Index Searches: 1
851
- Buffers: shared hit=2
852
- Planning Time: 0.029 ms
853
- Execution Time: 0.026 ms
854
- </screen>
855
-
856
- This variant of our <literal>IN</literal> query performed only 1 index
857
- search. It spent less time traversing the index (compared to the original
858
- query) because its <literal>IN</literal> construct uses values matching
859
- index tuples stored next to each other, on the same
860
- <structname>tenk1_thous_tenthous</structname> index leaf page.
861
- </para>
862
-
863
808
<para>
864
809
Another type of extra information is the number of rows removed by a
865
810
filter condition:
@@ -916,7 +861,6 @@ EXPLAIN ANALYZE SELECT * FROM polygon_tbl WHERE f1 @> polygon '(0.5,2.0)';
916
861
Index Scan using gpolygonind on polygon_tbl (cost=0.13..8.15 rows=1 width=85) (actual time=0.074..0.074 rows=0.00 loops=1)
917
862
Index Cond: (f1 @> '((0.5,2))'::polygon)
918
863
Rows Removed by Index Recheck: 1
919
- Index Searches: 1
920
864
Buffers: shared hit=1
921
865
Planning Time: 0.039 ms
922
866
Execution Time: 0.098 ms
@@ -950,10 +894,8 @@ EXPLAIN (ANALYZE, BUFFERS OFF) SELECT * FROM tenk1 WHERE unique1 < 100 AND un
950
894
-> BitmapAnd (cost=25.07..25.07 rows=10 width=0) (actual time=0.100..0.101 rows=0.00 loops=1)
951
895
-> Bitmap Index Scan on tenk1_unique1 (cost=0.00..5.04 rows=100 width=0) (actual time=0.027..0.027 rows=100.00 loops=1)
952
896
Index Cond: (unique1 < 100)
953
- Index Searches: 1
954
897
-> Bitmap Index Scan on tenk1_unique2 (cost=0.00..19.78 rows=999 width=0) (actual time=0.070..0.070 rows=999.00 loops=1)
955
898
Index Cond: (unique2 > 9000)
956
- Index Searches: 1
957
899
Planning Time: 0.162 ms
958
900
Execution Time: 0.143 ms
959
901
</screen>
@@ -981,7 +923,6 @@ EXPLAIN ANALYZE UPDATE tenk1 SET hundred = hundred + 1 WHERE unique1 < 100;
981
923
Buffers: shared hit=4 read=2
982
924
-> Bitmap Index Scan on tenk1_unique1 (cost=0.00..5.04 rows=100 width=0) (actual time=0.031..0.031 rows=100.00 loops=1)
983
925
Index Cond: (unique1 < 100)
984
- Index Searches: 1
985
926
Buffers: shared read=2
986
927
Planning Time: 0.151 ms
987
928
Execution Time: 1.856 ms
@@ -1120,7 +1061,6 @@ EXPLAIN ANALYZE SELECT * FROM tenk1 WHERE unique1 < 100 AND unique2 > 9000
1120
1061
Index Cond: (unique2 > 9000)
1121
1062
Filter: (unique1 < 100)
1122
1063
Rows Removed by Filter: 287
1123
- Index Searches: 1
1124
1064
Buffers: shared hit=16
1125
1065
Planning Time: 0.077 ms
1126
1066
Execution Time: 0.086 ms
0 commit comments