0
我想問爲什麼通過執行一個簡單的查詢優化器決定執行seq掃描兩次使用相同的過濾器在最後附加結果?在相同的過濾器上的多個seq掃描
SELECT count(*)
FROM customers c
WHERE ((name IS NOT NULL) AND (flag = 4) AND (birth_date < now()));
的PostgreSQL 9.3.4版本EXPLAIN 輸出分析一下:
Aggregate (cost=4444780.90..4444780.91 rows=1 width=0) (actual time=50654.137..50654.137 rows=1 loops=1)
-> Append (cost=0.00..4444776.28 rows=1847 width=0) (actual time=50654.128..50654.128 rows=0 loops=1)
-> Seq Scan on customers c (cost=0.00..4439681.76 rows=1845 width=0) (actual time=50614.774..50614.774 rows=0 loops=1)
Filter: ((name IS NOT NULL) AND (flag = 4) AND (birth_date < now()))
-> Seq Scan on customers c (cost=0.00..5094.52 rows=2 width=0) (actual time=39.349..39.349 rows=0 loops=1)
Filter: ((name IS NOT NULL) AND (flag = 4) AND (birth_date < now()))
Total runtime: 50654.245 ms
你解釋輸出不符合您的聲明(如沒有在你的聲明沒有聚集,然而存在一個總通話解釋輸出)。請向我們展示您正在運行的完整/真實聲明 –
是的,對不起,它只是不*但計數(*) – Borys
您能提供一個獨立的可運行示例來證明這一點嗎?它看起來很奇怪。 –