Re: [GENERAL] A slow query - Help please?

2006-06-21 Thread Martijn van Oosterhout
On Wed, Jun 21, 2006 at 04:12:08PM +0200, Alban Hertroys wrote: > Martijn van Oosterhout wrote: > >ISTM that what would really work well is some kind of "Merge Sort" node > >that would work by having multiple subnodes which are already sorted > >and merging them into one sorted list. > > Would...

Re: [GENERAL] A slow query - Help please?

2006-06-21 Thread Alban Hertroys
Martijn van Oosterhout wrote: ISTM that what would really work well is some kind of "Merge Sort" node that would work by having multiple subnodes which are already sorted and merging them into one sorted list. Would... So this isn't available yet? The planner would use this whenever it saw a

Re: [GENERAL] A slow query - Help please?

2006-06-21 Thread Alban Hertroys
Alban Hertroys wrote: Jim Nasby wrote: Probably a better bet would be going to 8.1 and using constraint elimination. Maybe you mean constraint exclusion? If so, is that going to help excluding partitions (basically the same thing, it seems) from a query based on an ORDER BY and a LIMIT?

Re: [GENERAL] A slow query - Help please?

2006-06-21 Thread Martijn van Oosterhout
On Wed, Jun 21, 2006 at 11:56:27AM +0200, Alban Hertroys wrote: > Say we take the query I posted: > "SELECT * FROM mm_posrel ORDER BY number DESC LIMIT 25;" > and the knowledge that this table is inherited by two other tables, with > number being unique across them (though PostgreSQL probabl

Re: [GENERAL] A slow query - Help please?

2006-06-21 Thread Alban Hertroys
Jim Nasby wrote: On Jun 19, 2006, at 7:00 AM, Alban Hertroys wrote: Now all we need to do is getting MMBase to do its queries like this :P Probably a better bet would be going to 8.1 and using constraint elimination. I searched the documentation, google and wikipedia for "constraint eli

Re: [GENERAL] A slow query - Help please?

2006-06-20 Thread hubert depesz lubaczewski
On 6/19/06, Alban Hertroys <[EMAIL PROTECTED]> wrote: I found a way that works, and is indeed quite a bit faster. It is evenuglier than what you proposed. The problem wasn't the "order by" in thesubquery, but the "order by" combined with the "union": sorry, i always forget about  the fact that unio

Re: [GENERAL] A slow query - Help please?

2006-06-19 Thread Jim Nasby
On Jun 19, 2006, at 7:00 AM, Alban Hertroys wrote: Now all we need to do is getting MMBase to do its queries like this :P Probably a better bet would be going to 8.1 and using constraint elimination. -- Jim C. Nasby, Sr. Engineering Consultant [EMAIL PROTECTED] Pervasive Software h

Re: [GENERAL] A slow query - Help please?

2006-06-19 Thread Alban Hertroys
hubert depesz lubaczewski wrote: in case you can't, do something similar to this: select * from ( select * from only table_a order by number desc limit 25 union select * from only table_b order by number desc limit 25 union select * from only table_c order by number desc limit 25 ) x order by

Re: [GENERAL] A slow query - Help please?

2006-06-19 Thread Gurjeet Singh
Hubert said 'do "something similar" to this'... The syntax was incorrect for sure. If you wish to be able to do ORDER BY and LIMIT in UNION queries, you need to make them sub-queries "something similar" to this: select * from ( select * from (select * from only table_a order by number desc limi

Re: [GENERAL] A slow query - Help please?

2006-06-19 Thread Alban Hertroys
hubert depesz lubaczewski wrote: ditch the inheritance. it is no good, and makes everything too complicated to work with. Would love to, but that's what the system we use generates (MMBase, for the record). We can probably rework the generated tables, but it isn't entirely certain that won't

Re: [GENERAL] A slow query - Help please?

2006-06-17 Thread hubert depesz lubaczewski
On 6/16/06, Alban Hertroys <[EMAIL PROTECTED]> wrote: We really need this solved. Isn't anybody able to shed some light onthis? Is it possible to make this query use an index scan, preferablyw/o disabling sequential scanning?ditch the inheritance. it is no good, and makes everything too complicated

Re: [GENERAL] A slow query - Help please?

2006-06-16 Thread Alban Hertroys
Alban Hertroys wrote: Hi all, We're using some 3rd party product that uses inheritence, and the following query is rather slow on PostgreSQL 7.4.7 (debian stable). Any suggestions how to speed it up? We really need this solved. Isn't anybody able to shed some light on this? Is it possible t

Re: [GENERAL] A slow query

2006-06-13 Thread Alban Hertroys
Alban Hertroys wrote: Hi all, We're using some 3rd party product that uses inheritence, and the following query is rather slow on PostgreSQL 7.4.7 (debian stable). Any suggestions how to speed it up? A few more datapoints: - Database was vacuum full analyzed just before the query. - The same