Re: [GENERAL] Finding latest record for a number of groups in an INSERT-only table

2011-07-05 Thread Chris Travers
It seems to me one solution is to alter your table topology by partitioning your table by the keys you need to query on, and then using simple aggregates. You;d have to set up ON INSERT DO INSTEAD rules, and you might get a performance hit. Another solution might be to break up the query int

Re: [GENERAL] Finding latest record for a number of groups in an INSERT-only table

2011-07-05 Thread Daniel Farina
On Tue, Jul 5, 2011 at 9:49 AM, Alban Hertroys wrote: > On 5 Jul 2011, at 9:13, Daniel Farina wrote: > >>> Setup a materialized view. >> >> This rather defeats the point AFAIK, because keeping the materialized >> view up to date (being more than thirty seconds out of date is not >> desirable) will

Re: [GENERAL] Finding latest record for a number of groups in an INSERT-only table

2011-07-05 Thread Alban Hertroys
On 5 Jul 2011, at 9:13, Daniel Farina wrote: >> Setup a materialized view. > > This rather defeats the point AFAIK, because keeping the materialized > view up to date (being more than thirty seconds out of date is not > desirable) will be expensive. Maintaining the index on the (key, > recency)

Re: [GENERAL] Finding latest record for a number of groups in an INSERT-only table

2011-07-05 Thread Gavin Flower
On 05/07/11 11:48, Daniel Farina wrote: This is basically exactly the same as http://archives.postgresql.org/pgsql-sql/2008-10/msg9.php; I'm just asking again, to see if thinking on the problem has changed: The basic problem, restated, is one has a relation with tuples like this: (key, rece

Re: [GENERAL] Finding latest record for a number of groups in an INSERT-only table

2011-07-05 Thread Daniel Farina
On Tue, Jul 5, 2011 at 12:32 AM, Simon Riggs wrote: > I think its a pretty common requirement and we should be looking to > optimize it if it isn't handled well. I agree; although I wanted to be sure that it is not in fact handled well by some mechanism I haven't seen yet. > The only problem is

Re: [GENERAL] Finding latest record for a number of groups in an INSERT-only table

2011-07-05 Thread Simon Riggs
On Tue, Jul 5, 2011 at 12:48 AM, Daniel Farina wrote: > This is basically exactly the same as > http://archives.postgresql.org/pgsql-sql/2008-10/msg9.php; I'm > just asking again, to see if thinking on the problem has changed: > > The basic problem, restated, is one has a relation with tuples

Re: [GENERAL] Finding latest record for a number of groups in an INSERT-only table

2011-07-05 Thread Daniel Farina
On Mon, Jul 4, 2011 at 11:55 PM, Alban Hertroys wrote: > On 5 Jul 2011, at 3:23, David Johnston wrote: > >>> Does anyone have fresh thoughts or suggestions for dealing with >>> INSERT-mostly tables conceived in this manner? > > You're struggling with read-performance in an INSERT-mostly table? Whe

Re: [GENERAL] Finding latest record for a number of groups in an INSERT-only table

2011-07-04 Thread Alban Hertroys
On 5 Jul 2011, at 3:23, David Johnston wrote: >> Does anyone have fresh thoughts or suggestions for dealing with >> INSERT-mostly tables conceived in this manner? You're struggling with read-performance in an INSERT-mostly table? Where are your performance priorities, on INSERT or on SELECT? >

Re: [GENERAL] Finding latest record for a number of groups in an INSERT-only table

2011-07-04 Thread David Johnston
On Jul 4, 2011, at 19:48, Daniel Farina wrote: > This is basically exactly the same as > http://archives.postgresql.org/pgsql-sql/2008-10/msg9.php; I'm > just asking again, to see if thinking on the problem has changed: > > The basic problem, restated, is one has a relation with tuples lik