Re: [PERFORM] analyzing intermediate query

2008-12-02 Thread Scott Carey
(dokumnr); -Original Message- From: Andrus [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2008 10:59 AM To: Scott Carey; pgsql-performance@postgresql.org; PFC Subject: Re: [PERFORM] analyzing intermediate query Scott, >Often times, switching an inner subselect that requires a distinct

Re: [PERFORM] analyzing intermediate query

2008-12-02 Thread Andrus
Scott, Often times, switching an inner subselect that requires a distinct to a group by on that column yields better results. In this case, the IN should be equivalent, so it probably will not help. This would look like: SELECT dok.* FROM dok JOIN (SELECT dokumnr FROM temptbl GROUP BY dok

Re: [PERFORM] analyzing intermediate query

2008-12-02 Thread Scott Carey
[EMAIL PROTECTED] Sent: Tuesday, December 02, 2008 7:50 AM To: pgsql-performance@postgresql.org; PFC Subject: Re: [PERFORM] analyzing intermediate query > Oh, I just thought about something, I don't remember in which version it > was added, but : > > EXPLAIN ANALYZE SELECT sum(colu

Re: [PERFORM] analyzing intermediate query

2008-12-02 Thread Andrus
Oh, I just thought about something, I don't remember in which version it was added, but : EXPLAIN ANALYZE SELECT sum(column1) FROM (VALUES ...a million ntegers... ) AS v Postgres is perfectly happy with that ; it's either a bit slow (about 1 second) or very fast depending on how you view th

Re: [PERFORM] analyzing intermediate query

2008-12-02 Thread PFC
My list can contain 1 .. 10 records and table contains 300 records and is growing. Ah. No IN(), then ;) Temp table + ANALYZE seems your only option... In 8.3 or 8.4 I think that IN() or temp table produce exactly the same result. Andrus. Oh, I just thought about something,

Re: [PERFORM] analyzing intermediate query

2008-12-02 Thread Andrus
My list can contain 1 .. 10 records and table contains 300 records and is growing. Ah. No IN(), then ;) Temp table + ANALYZE seems your only option... In 8.3 or 8.4 I think that IN() or temp table produce exactly the same result. Andrus. -- Sent via pgsql-performance mailing l

Re: [PERFORM] analyzing intermediate query

2008-12-02 Thread PFC
My list can contain 1 .. 10 records and table contains 300 records and is growing. Ah. No IN(), then ;) Temp table + ANALYZE seems your only option... -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription:

Re: [PERFORM] analyzing intermediate query

2008-12-02 Thread Andrus
Generally if you know your temptbl will always contains a few rows (say, generally a few and never more than a few thousands) it is better to use something like that : - get list of items - SELECT * FROM table WHERE id IN (...) My list can contain 1 .. 10 records and table contains 3

Re: [PERFORM] analyzing intermediate query

2008-12-02 Thread PFC
I noticed that query SELECT dok.* FROM dok JOIN (SELECT DISTINCT dokumnr FROM temptbl ) x USING(dokumnr); is slow in 8.1.4 I cannot use explain analyze since this query uses results from temporary table temptbl which is not available. Generally if you know your temptbl will always contai

[PERFORM] analyzing intermediate query

2008-12-02 Thread Andrus
I noticed that query SELECT dok.* FROM dok JOIN (SELECT DISTINCT dokumnr FROM temptbl ) x USING(dokumnr); is slow in 8.1.4 I cannot use explain analyze since this query uses results from temporary table temptbl which is not available. Sometimes innter table returns only 1 row so maybe seq s