Re: BUG #5542: Query optimization problem

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Roman <zotov(at)oe-it(dot)ru>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5542: Query optimization problem
Date: 2010-07-09 02:29:23
Message-ID: AANLkTilrRoFkqoUyPW2A50HyQ2fydOG_zoH3cbCoYdB8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Jul 6, 2010 at 2:43 AM, Roman <zotov(at)oe-it(dot)ru> wrote:
> I have a query:
>
> SELECT d1.ID, d2.ID
> FROM DocPrimary d1
>  JOIN DocPrimary d2 ON d2.BasedOn=d1.ID
> WHERE (d1.ID=234409763) or (d2.ID=234409763)
>
> i think what QO(Query Optimizer) can make it faster (now it seq scan and on
> million records works 7 sec)
>
> SELECT d1.ID, d2.ID
> FROM DocPrimary d1
>  JOIN DocPrimary d2 ON d2.BasedOn=d1.ID
> WHERE (d2.BasedOn=234409763) or (d2.ID=234409763)

EXPLAIN ANALYZE output for both queries, please?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Craig Ringer 2010-07-09 02:58:25 Re: [TESTERS] Location of certs -Windows 7 SSL mode?
Previous Message Tom Lane 2010-07-08 16:00:05 Re: BUG #5547: not able to connect to postgres through the oracle using Linux ODBC driver for Postgres