私は900万行のテーブルを使って私のポストグルで遅いクエリをしています。Postgres 9.4.12遅いクエリ
問合せ:EXPLAIN (ANALYZE, BUFFERS) SELECT date_point, geo, alarms, status FROM tracking_master WHERE id_asset = 151 AND date_point >= '2017-07-21 19:20:05' AND date_point <= '2017-07-21 19:25:05' ORDER BY date_point asc LIMIT 1000
ここでクエリが(、BUFFERSをANALYZE)EXPLAIN:
Limit (cost=161175.31..161175.32 rows=1 width=579) (actual time=60734.109..60734.113 rows=5 loops=1)
Buffers: shared hit=23470 read=114350
-> Sort (cost=161175.31..161175.32 rows=1 width=579) (actual time=60734.107..60734.110 rows=5 loops=1)
Sort Key: date_point
Sort Method: quicksort Memory: 27kB
Buffers: shared hit=23470 read=114350
-> Index Scan using idx_tracking_master_id_asset on tracking_master (cost=0.43..161175.30 rows=1 width=579) (actual time=80.682..60734.081 rows=5 loops=1)
Index Cond: (id_asset = 151)
Filter: ((date_point >= '2017-07-21 19:20:05-03'::timestamp with time zone) AND (date_point <= '2017-07-21 19:25:05-03'::timestamp with time zone))
Rows Removed by Filter: 202512
Buffers: shared hit=23470 read=114350
Planning time: 0.204 ms
Execution time: 60734.152 ms
あなたが最適化しようとしているクエリは何ですか?テーブルはどのように定義されていますか?インデックス?何が改善されるかを知るには、より多くの情報が必要です。 – joanolo