pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feed(no subject)
2+ messages / 2 participants
[nested] [flat]
* (no subject)
@ 2005-10-24 15:08 Илья Конюхов <ilyakon@mail.ru>
0 siblings, 1 reply; 2+ messages in thread
From: Илья Конюхов @ 2005-10-24 15:08 UTC (permalink / raw)
To: pgsql-sql
> For example, consider the queres:
>
> SELECT * FROM table1 WHERE field1=1 AND field2=1;
>
> SELECT * FROM table1 WHERE field2=1 AND field1=1;
>
>
> These two queries are logically equivalent. But in all cases the planner generates a query plan that performs field1=1 condition, and then field2=1 condition, as there is a index on field1.
>
> Is it possible to instruct the PostgreSQL query planner to perform field2=1 condition first, and then field1=1 condition?
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
EXPLAIN [ ANALYZE ] [ VERBOSE ] statement
This command displays the execution plan that the PostgreSQL planner generates for the supplied statement.
This command displays plan ONLY! But I want to instruct the PostgreSQL query planner to perform field2=1 condition first, and then field1=1 condition.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re:
@ 2005-10-24 15:20 Silke Trissl <trissl@informatik.hu-berlin.de>
parent: Илья Конюхов <ilyakon@mail.ru>
0 siblings, 0 replies; 2+ messages in thread
From: Silke Trissl @ 2005-10-24 15:20 UTC (permalink / raw)
To: Илья Конюхов <ilyakon@mail.ru>; +Cc: pgsql-sql
Илья Конюхов wrote:
>>For example, consider the queres:
>>
>>SELECT * FROM table1 WHERE field1=1 AND field2=1;
>>
>>SELECT * FROM table1 WHERE field2=1 AND field1=1;
>>
>>
>>These two queries are logically equivalent. But in all cases the planner generates a query plan that performs field1=1 condition, and then field2=1 condition, as there is a index on field1.
>>
>>Is it possible to instruct the PostgreSQL query planner to perform field2=1 condition first, and then field1=1 condition?
>>
You might get the desired result, if you switch off the index scan:
set ENABLE_INDEXSCAN = OFF.
But there is no way to tell Postgres what to use first. Usually the
query planer is quite good, so there is no reason to fiddle around. And
why on earth would you like that. In the end you get the same result.
Hope, that helps
Silke
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-10-24 15:20 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-24 15:08 Илья Конюхов <ilyakon@mail.ru>
2005-10-24 15:20 ` Re: Silke Trissl <trissl@informatik.hu-berlin.de>
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