* from (select * from address.ao where ao_level=7) s1 limit 1;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..0.04 rows=1 width=138) (actual time=0.015..0.016 rows=1 loops=1)
Buffers: shared hit=1
-> Seq Scan on ao (cost=0.00..41682.72 rows=938579 width=138) (actual time=0.014..0.014 rows=1 loops=1)
Filter: (ao_level = 7)
Buffers: shared hit=1
Planning time: 0.140 ms
Execution time: 0.053 ms
(7 строк)
Или так?
network=# explain (analyze, buffers) select count(1)!=0 from (select * from address.ao where ao_level=7 limit 1) s1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------
Aggregate (cost=0.06..0.07 rows=1 width=0) (actual time=0.021..0.021 rows=1 loops=1)
Buffers: shared hit=1
-> Limit (cost=0.00..0.04 rows=1 width=0) (actual time=0.015..0.015 rows=1 loops=1)
Buffers: shared hit=1
-> Seq Scan on ao (cost=0.00..41682.72 rows=938579 width=0) (actual time=0.014..0.014 rows=1 loops=1)
Filter: (ao_level = 7)
Buffers: shared hit=1
Planning time: 0.152 ms
Execution time: 0.073 ms
(9 строк)
limit 1 в подзапрос нужно
Обсуждают сегодня