I am not clear how to use a trigger for this, I will need to look into that....
It is my understanding that Postgres does not have materialized views though (which I believe would solve this problem nicely) - am I mistaken?... - Greg >Net Virtual Mailing Lists wrote: >> Is there a way to create an index that would make this query be efficient >> and not perform a sequential scan? >> >> SELECT count(*) AS count,id FROM sometable GROUP BY id; > >Indexes cannot be used for retrieving results... > > >> .. I've considered creating a rule on this table which would put the >> results of this into another table anytime it is updated, but I thought >> there might be an easier way. > >I don't think that a rule could come useful in this case. IMHO you could >use triggers or a materialized view to store the results and speed up >things. > > >Best regards >-- >Matteo Beccati >http://phpadsnew.com/ >http://phppgads.com/ > ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings