- 580 名前:577 mailto:sage [2007/03/14(水) 10:42:41 ID:???]
- レスありがとうございます
>>578 何故か余計にコストが上がりました EXPLAIN ANALYZE select count(id) from xxxxxxxxxx; Aggregate (cost=31500.40..31500.40 rows=1 width=4) (actual time=10446.63..10446.63 rows=1 loops=1) -> Seq Scan on xxxxxxxxxx (cost=0.00..31485.92 rows=5792 width=4) (actual time=10409.76..10439.48 rows=5792 loops=1) Total runtime: 10446.90 msec (カラムidは明示的にPKEY指定はしていませんがindexは貼ってあります。) ----------------------------------- 変化なし、なら納得ですがコスト高になるのは不思議です… >>579 VACUUM FULL;後↓ EXPLAIN ANALYZE select count(*) from xxxxxxxxxx; Aggregate (cost=211.40..211.40 rows=1 width=0) (actual time=67.11..67.11 rows=1 loops=1) -> Seq Scan on xxxxxxxxxx (cost=0.00..196.92 rows=5792 width=0) (actual time=16.11..61.43 rows=5792 loops=1) Total runtime: 67.20 msec EXPLAIN ANALYZE select count(id) from xxxxxxxxxx; Aggregate (cost=211.40..211.40 rows=1 width=4) (actual time=21.54..21.54 rows=1 loops=1) -> Seq Scan on xxxxxxxxxx (cost=0.00..196.92 rows=5792 width=4) (actual time=0.05..15.98 rows=5792 loops=1) Total runtime: 21.65 msec ----------------------------------- 劇的に変わりました。 1週間に一度ほどの間隔で、レコードが全てが入れ替わるので CronでVACUUMを走らせていましたがVACUUM FULLすると 見違える程高速になりました。 SQL文のテクニックも必要ですがDB自体のメンテも大事、という事でしょうか。
|

|