From: Tom Lane <tgl@sss.pgh.pa.us>
To: Craig A. James <cjames@modgraph-usa.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Overriding the optimizer
Date: Sat, 17 Dec 2005 02:28:11 -0500
Message-ID: <4252.1134804491@sss.pgh.pa.us> (raw)
In-Reply-To: <43A22368.8060307@modgraph-usa.com>
References: <200512141603.52583.blargity@gmail.com>
<7484.1134600423@sss.pgh.pa.us>
<1134629567.14248.27.camel@firebolt>
<200512150148.16125.blargity@gmail.com>
<1134644526.14248.60.camel@firebolt>
<43A1C40D.8040006@paradise.net.nz>
<43A1F6DB.3080805@modgraph-usa.com>
<18537.1134692629@sss.pgh.pa.us>
<43A22368.8060307@modgraph-usa.com>
"Craig A. James" <cjames@modgraph-usa.com> writes:
> How about this: Instead of arguing in the abstract, tell me in
> concrete terms how you would address the very specific example I gave,
> where myfunc() is a user-written function. To make it a little more
> challenging, try this: myfunc() can behave very differently depending
> on the parameters, and sometimes (but not always), the application
> knows how it will behave and could suggest a good execution plan.
A word to the wise:
regression=# explain select * from tenk1 where ten > 5 and ten < 9
regression-# and myfunc(unique1,unique2);
QUERY PLAN
------------------------------------------------------------------
Seq Scan on tenk1 (cost=0.00..533.00 rows=982 width=244)
Filter: ((ten > 5) AND (ten < 9) AND myfunc(unique1, unique2))
(2 rows)
regression=# explain select * from tenk1 where myfunc(unique1,unique2)
regression-# and ten > 5 and ten < 9;
QUERY PLAN
------------------------------------------------------------------
Seq Scan on tenk1 (cost=0.00..533.00 rows=982 width=244)
Filter: (myfunc(unique1, unique2) AND (ten > 5) AND (ten < 9))
(2 rows)
I might have taken your original complaint more seriously if it
weren't so blatantly bogus. Your query as written absolutely
would not have evaluated myfunc() first, because there was no
reason for the planner to reorder the WHERE list.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, cjames@modgraph-usa.com
Subject: Re: Overriding the optimizer
In-Reply-To: <4252.1134804491@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox