x
select count(1) != 0 from ... where ... limit 1
vs
select exists(select 1 from ... where ... limit 1)
Size: a a a
x
select count(1) != 0 from ... where ... limit 1
select exists(select 1 from ... where ... limit 1)
DP
DP
AT
AT
AT
DP
s
DP
x
x
s
network=# explain (analyze, verbose, buffers) select exists(select 1 from address.ao where ao_level=7 limit 1);
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------
Result (cost=0.04..0.05 rows=1 width=0) (actual time=0.015..0.015 rows=1 loops=1)
Output: $0
Buffers: shared hit=1
InitPlan 1 (returns $0)
-> Seq Scan on address.ao (cost=0.00..41682.72 rows=938579 width=0) (actual time=0.012..0.012 rows=1 loops=1)
Filter: (ao.ao_level = 7)
Buffers: shared hit=1
Planning time: 0.840 ms
Execution time: 0.293 ms
(9 строк)
network=# explain (analyze, verbose, buffers) select count(1)!=0 from address.ao where ao_level=7 limit 1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------
Limit (cost=44029.17..44029.19 rows=1 width=0) (actual time=332.232..332.233 rows=1 loops=1)
Output: ((count(1) <> 0))
Buffers: shared hit=26692
-> Aggregate (cost=44029.17..44029.19 rows=1 width=0) (actual time=332.229..332.229 rows=1 loops=1)
Output: (count(1) <> 0)
Buffers: shared hit=26692
-> Seq Scan on address.ao (cost=0.00..41682.72 rows=938579 width=0) (actual time=0.012..238.177 rows=936664 loops=1)
Filter: (ao.ao_level = 7)
Rows Removed by Filter: 262594
Buffers: shared hit=26692
Planning time: 0.115 ms
Execution time: 332.273 ms
(12 строк)
s
DP
Seq Scan on address.ao (cost=0.00..41682.72 rows=938579 width=0) (actual time=0.012..0.012 rows=1 loops=1)
Seq Scan on address.ao (cost=0.00..41682.72 rows=938579 width=0) (actual time=0.012..238.177 rows=936664 loops=1)
mit 1 н
ам ничего не дал?rt г
де-то затесался?s
Seq Scan on address.ao (cost=0.00..41682.72 rows=938579 width=0) (actual time=0.012..0.012 rows=1 loops=1)
Seq Scan on address.ao (cost=0.00..41682.72 rows=938579 width=0) (actual time=0.012..238.177 rows=936664 loops=1)
mit 1 н
ам ничего не дал?rt г
де-то затесался?