Tuesday, 3 September 2013

Speed up Group by in postgres

Speed up Group by in postgres

Hi i want to create an statistic select in postgres
createddate is an timestamp without timezone
SELECT createddate, count(*) FROM useractivitystatisticsentity GROUP BY
createddate
The plan looks like that
GroupAggregate (cost=232569.83..256698.22 rows=1378765 width=8)
-> Sort (cost=232569.83..236016.75 rows=1378765 width=8)
Sort Key: createddate
-> Seq Scan on useractivitystatisticsentity (cost=0.00..54268.65
rows=1378765 width=8)
but the plan didn't change after adding an index
CREATE INDEX ysdfg
ON useractivitystatisticsentity
USING btree
(createddate );
any ideas how to speed tings up? it takes about 100sec at 1.000.000 rows

No comments:

Post a Comment