From: Mark Mielke <mark@mark.mielke.cc>
To: Albert Cervera Areny <albert@sedifa.com>
Cc: Richard Huxton <dev@archonet.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Posible planner improvement?
Date: Wed, 21 May 2008 07:24:55 -0400
Message-ID: <48340687.9010501@mark.mielke.cc> (raw)
In-Reply-To: <200805211311.25016.albert@sedifa.com>
References: <200805211228.48248.albert@sedifa.com>
<4833FDE5.8090603@archonet.com>
<200805211311.25016.albert@sedifa.com>
A Dimecres 21 Maig 2008, Richard Huxton va escriure:
>> Albert Cervera Areny wrote:
>>
>>> I've got a query similar to this:
>>>
>>> select * from t1, t2 where t1.id > 158507 and t1.id = t2.id;
>>>
>>> That took > 84 minutes (the query was a bit longer but this is the part
>>> that made the difference) after a little change the query took ~1 second:
>>>
>>> select * from t1, t2 where t1.id > 158507 and t2.id > 158507 and t1.id =
>>> t2.id;
>>>
>> Try posting EXPLAIN ANALYSE SELECT ... for both of those queries and
>> we'll see why it's better at the second one.
>>
Even if the estimates were off (they look a bit off for the first
table), the above two queries are logically identical, and I would
expect the planner to make the same decision for both.
I am curious - what is the result of:
select * from t1, t2 where t2.id > 158507 and t1.id = t2.id;
Is it the same speed as the first or second, or is a third speed entirely?
If t1.id = t2.id, I would expect the planner to substitute them freely
in terms of identities?
Cheers,
mark
--
Mark Mielke <mark@mielke.cc>
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: mark@mark.mielke.cc, albert@sedifa.com, dev@archonet.com
Subject: Re: Posible planner improvement?
In-Reply-To: <48340687.9010501@mark.mielke.cc>
* 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