Re: enforcing a join type

Lists: pgsql-generalpgsql-hackers
From: "Hicham G(dot) Elmongui" <elmongui(at)cs(dot)purdue(dot)edu>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: enforcing a join type
Date: 2004-08-04 20:53:58
Message-ID: 200408042053.i74KrwCm007012@newman.cs.purdue.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Hi,
If I want the planner/optimizer to always choose merge join when it needs to
join relations. How can I do it ?
Thanks,
--h


From: "Scott Marlowe" <smarlowe(at)qwest(dot)net>
To: "Hicham G(dot) Elmongui" <elmongui(at)cs(dot)purdue(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: enforcing a join type
Date: 2004-08-04 22:41:10
Message-ID: 1091659270.27166.146.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

On Wed, 2004-08-04 at 14:53, Hicham G. Elmongui wrote:
> Hi,
> If I want the planner/optimizer to always choose merge join when it needs to
> join relations. How can I do it ?

>From my past experience, I'd guess what you're really trying to do is
STOP the planner from choosing a nested_loop join, in which case it's
quite easy:

set enable_nestloop = off;
select * from ...

Of course, you could apply the same basic trick to all other join
methods, and postgresql would then favor using the merge join.


From: "Hicham G(dot) Elmongui" <elmongui(at)cs(dot)purdue(dot)edu>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: enforcing a join type
Date: 2004-08-04 23:26:05
Message-ID: 200408042326.i74NQ6Cm008563@newman.cs.purdue.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

I didn't mean about doing this from a front end. I want to disable
nested_loop and hash_join from the backend.
I tried to set the variables (enable_nestloop and enable_hashjoin) in
costsize.c, but this didn't do it.
Thanks,
--h

-----Original Message-----
From: Scott Marlowe [mailto:smarlowe(at)qwest(dot)net]
Sent: Wednesday, August 04, 2004 5:41 PM
To: Hicham G. Elmongui
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] enforcing a join type

On Wed, 2004-08-04 at 14:53, Hicham G. Elmongui wrote:
> Hi,
> If I want the planner/optimizer to always choose merge join when it needs
to
> join relations. How can I do it ?

>From my past experience, I'd guess what you're really trying to do is
STOP the planner from choosing a nested_loop join, in which case it's
quite easy:

set enable_nestloop = off;
select * from ...

Of course, you could apply the same basic trick to all other join
methods, and postgresql would then favor using the merge join.


From: "Scott Marlowe" <smarlowe(at)qwest(dot)net>
To: "Hicham G(dot) Elmongui" <elmongui(at)cs(dot)purdue(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: [HACKERS] enforcing a join type
Date: 2004-08-04 23:41:52
Message-ID: 1091662912.27166.151.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

As this is not really a hacking issue, I'm moving it out of hackers and
into general. Please post all replies there not in hackers.

Anyway, I'm afraid I'd have to ask WHY you're trying to just disable
it? Is the query planner making the wrong decision with good
statistics, or are you getting bad statistics?

Can you post an explain analyze of the query(s) that are making you want
to make this change? Just turning off a join method isn't the way to
fix PostgreSQL, getting it to pick the right one is.

On Wed, 2004-08-04 at 17:26, Hicham G. Elmongui wrote:
> I didn't mean about doing this from a front end. I want to disable
> nested_loop and hash_join from the backend.
> I tried to set the variables (enable_nestloop and enable_hashjoin) in
> costsize.c, but this didn't do it.
> Thanks,
> --h
>
>
>
>
> -----Original Message-----
> From: Scott Marlowe [mailto:smarlowe(at)qwest(dot)net]
> Sent: Wednesday, August 04, 2004 5:41 PM
> To: Hicham G. Elmongui
> Cc: pgsql-hackers(at)postgresql(dot)org
> Subject: Re: [HACKERS] enforcing a join type
>
> On Wed, 2004-08-04 at 14:53, Hicham G. Elmongui wrote:
> > Hi,
> > If I want the planner/optimizer to always choose merge join when it needs
> to
> > join relations. How can I do it ?
>
> >From my past experience, I'd guess what you're really trying to do is
> STOP the planner from choosing a nested_loop join, in which case it's
> quite easy:
>
> set enable_nestloop = off;
> select * from ...
>
> Of course, you could apply the same basic trick to all other join
> methods, and postgresql would then favor using the merge join.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>


From: "Hicham G(dot) Elmongui" <elmongui(at)cs(dot)purdue(dot)edu>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: enforcing a join type
Date: 2004-08-04 23:48:22
Message-ID: 200408042348.i74NmNCm008728@newman.cs.purdue.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

Maybe I didn't make myself clear enough. I didn't have a problem with
postgresql. I am just playing around with the code, tracing some parts in
order to understand the code well.
This is just an experiment with the code. That's why I posted it to hackers.
Please let me know if this is still the wrong place for this question.
--h

-----Original Message-----
From: Scott Marlowe [mailto:smarlowe(at)qwest(dot)net]
Sent: Wednesday, August 04, 2004 6:42 PM
To: Hicham G. Elmongui
Cc: pgsql-hackers(at)postgresql(dot)org; pgsql-general(at)postgresql(dot)org
Subject: Re: [HACKERS] enforcing a join type

As this is not really a hacking issue, I'm moving it out of hackers and
into general. Please post all replies there not in hackers.

Anyway, I'm afraid I'd have to ask WHY you're trying to just disable
it? Is the query planner making the wrong decision with good
statistics, or are you getting bad statistics?

Can you post an explain analyze of the query(s) that are making you want
to make this change? Just turning off a join method isn't the way to
fix PostgreSQL, getting it to pick the right one is.

On Wed, 2004-08-04 at 17:26, Hicham G. Elmongui wrote:
> I didn't mean about doing this from a front end. I want to disable
> nested_loop and hash_join from the backend.
> I tried to set the variables (enable_nestloop and enable_hashjoin) in
> costsize.c, but this didn't do it.
> Thanks,
> --h
>
>
>
>
> -----Original Message-----
> From: Scott Marlowe [mailto:smarlowe(at)qwest(dot)net]
> Sent: Wednesday, August 04, 2004 5:41 PM
> To: Hicham G. Elmongui
> Cc: pgsql-hackers(at)postgresql(dot)org
> Subject: Re: [HACKERS] enforcing a join type
>
> On Wed, 2004-08-04 at 14:53, Hicham G. Elmongui wrote:
> > Hi,
> > If I want the planner/optimizer to always choose merge join when it
needs
> to
> > join relations. How can I do it ?
>
> >From my past experience, I'd guess what you're really trying to do is
> STOP the planner from choosing a nested_loop join, in which case it's
> quite easy:
>
> set enable_nestloop = off;
> select * from ...
>
> Of course, you could apply the same basic trick to all other join
> methods, and postgresql would then favor using the merge join.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>


From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: "Hicham G(dot) Elmongui" <elmongui(at)cs(dot)purdue(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: enforcing a join type
Date: 2004-08-05 01:28:23
Message-ID: 41118D37.4050802@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

> If I want the planner/optimizer to always choose merge join when it needs to
> join relations. How can I do it ?

You can't, unless in your transaction you set enable_nestloop,
enable_seqscan, etc. all to off except for the join type you want.

Chris


From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: "Hicham G(dot) Elmongui" <elmongui(at)cs(dot)purdue(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: enforcing a join type
Date: 2004-08-05 01:32:42
Message-ID: 41118E3A.4090603@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-hackers

> I didn't mean about doing this from a front end. I want to disable
> nested_loop and hash_join from the backend.
> I tried to set the variables (enable_nestloop and enable_hashjoin) in
> costsize.c, but this didn't do it.

Turn them off in your postgresql.conf then.

Chris