| 注意,在此步骤中记录的数量减少到7,847条。 postgres=# explain (analyze,verbose,timing,costs,buffers) select ctid from tbl   where crt_time between 2017-07-22 17:59:34 and 2017-07-22 17:59:40   and (   c1 in (1,2,3,4,100,200,99,88,77,66,55)   or   c2 < 10   );   QUERY PLAN  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------   Bitmap Heap Scan on postgres.tbl (cost=35025.85..44822.94 rows=7576 width=6) (actual time=205.577..214.821 rows=7847 loops=1)   Output: ctid   Recheck Cond: (((tbl.c1 = ANY ( {1,2,3,4,100,200,99,88,77,66,55} ::integer[])) OR (tbl.c2 < 10)) AND (tbl.crt_time >= 2017-07-22 17:59:34 ::timestamp without time zone) AND (tbl.crt_time <= 2017-07-22 17:59:40 ::timestamp without time zone))   Heap Blocks: exact=6983   Buffers: shared hit=14343   -> BitmapAnd (cost=35025.85..35025.85 rows=7581 width=0) (actual time=204.048..204.048 rows=0 loops=1)   Buffers: shared hit=7360   -> BitmapOr (cost=1621.11..1621.11 rows=153936 width=0) (actual time=70.279..70.279 rows=0 loops=1)   Buffers: shared hit=141   -> Bitmap Index Scan on idx_tbl_1 (cost=0.00..806.54 rows=54151 width=0) (actual time=15.860..15.860 rows=54907 loops=1)   Index Cond: (tbl.c1 = ANY ( {1,2,3,4,100,200,99,88,77,66,55} ::integer[]))   Buffers: shared hit=88   -> Bitmap Index Scan on idx_tbl_1 (cost=0.00..810.79 rows=99785 width=0) (actual time=54.418..54.418 rows=95147 loops=1)   Index Cond: (tbl.c2 < 10)   Buffers: shared hit=53   -> Bitmap Index Scan on idx_tbl_2 (cost=0.00..33402.60 rows=2462443 width=0) (actual time=127.101..127.101 rows=2640751 loops=1)   Index Cond: ((tbl.crt_time >= 2017-07-22 17:59:34 ::timestamp without time zone) AND (tbl.crt_time <= 2017-07-22 17:59:40 ::timestamp without time zone))   Buffers: shared hit=7219   Planning time: 0.203 ms   Execution time: 216.697 ms  (20 rows) 
 然后,看KNN的扫描时间: 注意,60,687条记录满足KNN距离条件,所以接下来将解释CTID合并扫描与原始扫描之间的性能比较。 postgres=# explain (analyze,verbose,timing,costs,buffers) select * from ff(point (0,0) ,5,1000000);   QUERY PLAN  ----------------------------------------------------------------------------------------------------------------------   Function Scan on postgres.ff (cost=0.25..10.25 rows=1000 width=6) (actual time=188.563..192.114 rows=60687 loops=1)   Output: ff   Function Call: ff( (0,0) ::point, 5 ::double precision, 1000000)   Buffers: shared hit=61296   Planning time: 0.029 ms   Execution time: 195.097 ms  (6 rows) 
 (编辑:南平站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |