Re: [PERFORM] Trying to eliminate union and sort

2013-07-17 Thread Vitalii Tymchyshyn
I'd try to check why discounts are different. Join with 'or' should work. Build (one query) except all (another query) and check some rows from result. 13 лип. 2013 01:28, Brian Fehrle bri...@consistentstate.com напис. On 07/11/2013 06:46 PM, Josh Berkus wrote: Brian, 3. I'm trying to

Re: [PERFORM] Trying to eliminate union and sort

2013-07-15 Thread Brian Fehrle
On 07/12/2013 04:43 PM, Josh Berkus wrote: As for the counts on the tables: table1 3,653,472 table2 2,191,314 table325,676,589 I think it's safe to assume right now that any resulting joins are not one-to-one Hmmm? How is doing a subselect in the SELECT clause even working,

Re: [PERFORM] Trying to eliminate union and sort

2013-07-15 Thread Marc Mamin
-performance@postgresql.org Betreff: Re: [PERFORM] Trying to eliminate union and sort On 07/12/2013 04:43 PM, Josh Berkus wrote: As for the counts on the tables: table1 3,653,472 table2 2,191,314 table325,676,589 I think it's safe to assume right now that any resulting joins

Re: [PERFORM] Trying to eliminate union and sort

2013-07-12 Thread Brian Fehrle
On 07/11/2013 06:46 PM, Josh Berkus wrote: Brian, 3. I'm trying to eliminate the union, however I have two problems. A) I can't figure out how to have an 'or' clause in a single join that would fetch all the correct rows. If I just do: LEFT OUTER JOIN table2 t2 ON (t2.real_id = t.id OR

Re: [PERFORM] Trying to eliminate union and sort

2013-07-12 Thread Josh Berkus
As for the counts on the tables: table1 3,653,472 table2 2,191,314 table325,676,589 I think it's safe to assume right now that any resulting joins are not one-to-one Hmmm? How is doing a subselect in the SELECT clause even working, then? -- Josh Berkus PostgreSQL

[PERFORM] Trying to eliminate union and sort

2013-07-11 Thread Brian Fehrle
Hi All, (basic info) PostgreSQL 9.2.4 64 bit Linux host 4GB shared_buffers with 14GB system memory, dedicated database VM 10MB work_mem I have a query that takes over 6 minutes to complete, and it's due mainly to the two sorting operations being done on this query. The data it is returning

Re: [PERFORM] Trying to eliminate union and sort

2013-07-11 Thread Josh Berkus
Brian, 3. I'm trying to eliminate the union, however I have two problems. A) I can't figure out how to have an 'or' clause in a single join that would fetch all the correct rows. If I just do: LEFT OUTER JOIN table2 t2 ON (t2.real_id = t.id OR t2.real_id = t.backup_id), I end up with many