[GENERAL] join question

2008-10-22 Thread Grzegorz Jaśkiewicz
Hey folks, I am trying to rewrite a query here, that takes 1.5m atm to finish. I got it down to 20s, and still trying to pin it down. basically, a query looks something like that atm: select a.*, b.* from a join b on a.id = b.a_id and a.banned true where a.start = now() and b.end

Re: [GENERAL] join question

2008-10-22 Thread Tom Lane
=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= [EMAIL PROTECTED] writes: that's 20s query, and now I got it down to 10s , by using something - which in my eyes would be always wrong - and against all logic. So if someone could please explain to me why is it faster: [ shrug... ] If you aren't going to

Re: [GENERAL] join question

2008-10-22 Thread Grzegorz Jaśkiewicz
we're even more in the dark than you are. :) so here are the plans, that's the real table run. QUERY PLAN after

Re: [GENERAL] join question

2008-10-22 Thread Tom Lane
=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= [EMAIL PROTECTED] writes: so here are the plans, that's the real table run. Hmm, well this rowcount estimate is way off: - Hash Anti Join (cost=376.60..37791.22 rows=1 width=8) (actual time=15.195..8216.448 rows=2 loops=1) The

Re: [GENERAL] join question

2008-10-22 Thread Grzegorz Jaśkiewicz
On Thu, Oct 23, 2008 at 12:25 AM, Tom Lane [EMAIL PROTECTED] wrote: =?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= [EMAIL PROTECTED] writes: so here are the plans, that's the real table run. Hmm, well this rowcount estimate is way off: - Hash Anti Join (cost=376.60..37791.22

Re: [GENERAL] join question

2008-10-22 Thread marcin mank
Sort Method: external sort Disk: 1320kB One simple speedup could be upping Your work_mem to 2M for this query, so the sorts are in memory. btw: Last time I used Postgres, it did not show the sort method. Cool. Greetings Marcin Mank -- Sent via pgsql-general mailing list

Re: [GENERAL] join question

2008-10-22 Thread Grzegorz Jaśkiewicz
On Thu, Oct 23, 2008 at 12:25 AM, Tom Lane [EMAIL PROTECTED] wrote: It looks like you are testing a case where the tables all fit in memory. Do you expect that to be the reality for your production use? If so, you might want to reduce random_page_cost to something close to 1 to reflect it.

Re: [GENERAL] join question

2008-10-22 Thread Tom Lane
=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= [EMAIL PROTECTED] writes: On Thu, Oct 23, 2008 at 12:25 AM, Tom Lane [EMAIL PROTECTED] wrote: I'm not sure why the rowcount estimate is so far off, but the antijoin code is all new and probably there's an estimation bug in there somewhere. (You didn't get

Re: [GENERAL] join question

2008-10-22 Thread Grzegorz Jaśkiewicz
thanks. I shall try it.Also, thanks for putting my name in cvs log ;)

[GENERAL] Join Question

2006-08-02 Thread Chris Hoover
Question,What is the difference between left join, and left outer join?I know the difference between inner and outer joins, but I was thinking that left join == inner join. But from what I am now seeing, it appears that PG is equating left join to left outer join. Is this correct? Thanks,Chris

Re: [GENERAL] Join Question

2006-08-02 Thread Scott Marlowe
On Wed, 2006-08-02 at 14:32, Chris Hoover wrote: Question, What is the difference between left join, and left outer join? I know the difference between inner and outer joins, but I was thinking that left join == inner join. But from what I am now seeing, it appears that PG is equating

Re: [GENERAL] Join Question

2006-08-02 Thread Nikolay Samokhvalov
On 8/2/06, Chris Hoover [EMAIL PROTECTED] wrote: Question, What is the difference between left join, and left outer join? I know the difference between inner and outer joins, but I was thinking that left join == inner join. But from what I am now seeing, it appears that PG is equating left

Re: [GENERAL] Join question

2003-08-29 Thread Thomas A. Lowery
Does using a union count as one query? select a from tst_1 where b is null union select d from tst_2 t2 join tst_1 t1 on (t1.b = t2.c) where t1.b is NOT null On Thu, Aug 28, 2003 at 05:55:27PM -0400, Williams, Travis L, NEO wrote: Question, I have a table (1) with 2 col (a b) where b can

Re: [GENERAL] Join question

2003-08-29 Thread Williams, Travis L, NEO
Sure.. if it works.. I'm just trying to not have to make multiple calls to the DB.. I'll try it out.. Thanks, Travis -Original Message- From: Thomas A. Lowery [mailto:[EMAIL PROTECTED] Sent: Thursday, August 28, 2003 8:06 PM To: [EMAIL PROTECTED] Subject: Re: [GENERAL] Join question

Re: [GENERAL] Join question

2003-08-29 Thread Williams, Travis L, NEO
PROTECTED] Sent: Thursday, August 28, 2003 8:06 PM To: [EMAIL PROTECTED] Subject: Re: [GENERAL] Join question Does using a union count as one query? select a from tst_1 where b is null union select d from tst_2 t2 join tst_1 t1 on (t1.b = t2.c) where t1.b is NOT null On Thu, Aug 28, 2003 at 05:55:27PM

Re: [GENERAL] Join question

2003-08-29 Thread Thomas A. Lowery
: Thomas A. Lowery [mailto:[EMAIL PROTECTED] Sent: Thursday, August 28, 2003 8:06 PM To: [EMAIL PROTECTED] Subject: Re: [GENERAL] Join question Does using a union count as one query? select a from tst_1 where b is null union select d from tst_2 t2 join tst_1 t1 on (t1.b = t2.c) where t1

Re: [GENERAL] Join question

2003-08-29 Thread Williams, Travis L, NEO
Yeah.. so that's why I didn't know if I could do it all in the same statement. Travis -Original Message- From: Thomas A. Lowery [mailto:[EMAIL PROTECTED] Sent: Thursday, August 28, 2003 8:54 PM To: Williams, Travis L, NEO Cc: [EMAIL PROTECTED] Subject: Re: [GENERAL] Join question

Re: [GENERAL] Join question

2003-08-29 Thread Jeffrey Melloy
On Thursday, August 28, 2003, at 09:03 PM, Williams, Travis L, NEO wrote: I have a table1 with 2 col (a b) where b can sometimes be null. I need a query that if B is null I get back the contents of A.. but if B is not null I do a select d from table2 where d like '%b%' There is nothing to join

Re: [GENERAL] Join question

2003-08-29 Thread Williams, Travis L, NEO
29, 2003 12:44 AM To: Williams, Travis L, NEO Cc: Thomas A. Lowery; [EMAIL PROTECTED] Subject: Re: [GENERAL] Join question On Friday, August 29, 2003, at 12:36 AM, Williams, Travis L, NEO wrote: Performace wise would I be better off just doing 2 query's.. i.e. select a,b from table1