pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Илья Конюхов <ilyakon@mail.ru>
To: pgsql-sql@postgresql.org
Date: Mon, 24 Oct 2005 19:08:59 +0400
Message-ID: <E1EU3wZ-000Fgr-00.ilyakon-mail-ru@f21.mail.ru> (raw)

> 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.



view thread (2+ messages)  latest in thread

Message-ID: <E1EU3wZ-000Fgr-00.ilyakon-mail-ru@f21.mail.ru>
Permalink:  ../E1EU3wZ-000Fgr-00.ilyakon-mail-ru@f21.mail.ru/
Also on:    postgresql.org/message-id/E1EU3wZ-000Fgr-00.ilyakon-mail-ru@f21.mail.ru

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: ilyakon@mail.ru
  Subject: Re: 
  In-Reply-To: <E1EU3wZ-000Fgr-00.ilyakon-mail-ru@f21.mail.ru>
  References: <E1EU3wZ-000Fgr-00.ilyakon-mail-ru@f21.mail.ru>

* 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