pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Craig A. James <cjames@modgraph-usa.com>
To: pgsql-performance@postgresql.org
Subject: Re: Overriding the optimizer
Date: Thu, 15 Dec 2005 18:23:22 -0800
Message-ID: <43A2251A.60907@modgraph-usa.com> (raw )
In-Reply-To: <43A2203B.2050102@familyhealth.com.au >
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 >
<43A21D74.8030002@familyhealth.com.au >
<c2d9e70e0512151800l5561fc04q7ee79593dcb4ea5c@mail.gmail.com >
<43A2203B.2050102@familyhealth.com.au >
Christopher Kings-Lynne wrote:
>>>> select * from my_table where row_num >= 50000 and row_num <
>>>> 100000
>>>> and myfunc(foo, bar);
>>>
>>>
>>> You just create an index on myfunc(foo, bar)
>>
>>
>> only if myfunc(foo, bar) is immutable...
>
>
> And if it's not then the best any database can do is to index scan
> row_num - so still you have no problem.
Boy, you picked a *really* bad example ;-)
The problem is that Postgres decided to filter on myfunc() *first*, and then filter on row_num, resulting in a query time that jumped from seconds to hours. And there's no way for me to tell Postgres not to do that!
So, "you still have no problem" is exactly wrong, because Postgres picked the wrong plan. Postgres decided that applying myfunc() to 10,000,000 rows was a better plan than an index scan of 50,000 row_nums. So I'm screwed.
Craig
view thread (41+ messages) latest in thread
Message-ID: <43A2251A.60907@modgraph-usa.com>
Permalink: ../43A2251A.60907@modgraph-usa.com/
Also on: postgresql.org/message-id/43A2251A.60907@modgraph-usa.com
copy link · copy postgr.es
reply 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: cjames@modgraph-usa.com
Subject: Re: Overriding the optimizer
In-Reply-To: <43A2251A.60907@modgraph-usa.com>
* 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