Re: [PERFORM] Two fast queries get slow when combined

2007-10-31 Thread cluster
You are lying to us about how those queries were posed to Postgres (and no I don't feel a need to explain how I know). Sorry. The "lying" was not intended as explained in my reply to Heikku. Thanks for the tips anyways. ---(end of broadcast)--- T

Re: [PERFORM] Two fast queries get slow when combined

2007-10-31 Thread cluster
There's something odd about that plan. It's doing both a seq scan and a bitmap scan on "items", but I can't see stats table being mentioned anywhere. Huh? Aaah, sorry. I made a major search/replace-refactoring (that obviously went wrong) on all open files in the editor before posting to this

Re: [PERFORM] Two fast queries get slow when combined

2007-10-30 Thread Tom Lane
cluster <[EMAIL PROTECTED]> writes: > Queries and output from EXPLAIN ANALYZE can be seen here with some > syntax highlighting: > http://rafb.net/p/BJIW4p69.html You are lying to us about how those queries were posed to Postgres (and no I don't feel a need to explain how I know). In future p

Re: [PERFORM] Two fast queries get slow when combined

2007-10-30 Thread Heikki Linnakangas
cluster wrote: SELECT keyId, sortNum, count(1) FROM stats s, items i WHERE s.keyId = i.keyId AND i.sortNum > 123 GROUP BY i.keyId, i.sortNum ORDER BY i.sortNum LIMIT 50 Limit (cost=3281.72..3281.84 rows=50 width=16) (actual time=435.838..436.043 rows=50 loops=1) InitPlan -

[PERFORM] Two fast queries get slow when combined

2007-10-30 Thread cluster
I have two small queries which are both very fast to evaluate separately. The first query, "Query 1", calculates some statistics and the the second query, "Query 2", finds a subset of relevant keys. When combined into a single query which calculates statistics from only the subset of relevant ke