On Tue, Jul 20, 2010 at 09:57:06AM +0400, Zotov wrote:
>  SELECT d1.ID, d2.ID
>  FROM DocPrimary d1
>    JOIN DocPrimary d2 ON d2.BasedOn=d1.ID
>  WHERE (d1.ID=234409763) or (d2.ID=234409763)

You could try rewriting it to:

    SELECT d1.ID, d2.ID
    FROM DocPrimary d1
      JOIN DocPrimary d2 ON d2.BasedOn=d1.ID
    WHERE d1.ID=234409763
  UNION
    SELECT d1.ID, d2.ID
    FROM DocPrimary d1
      JOIN DocPrimary d2 ON d2.BasedOn=d1.ID
    WHERE d2.ID=234409763

This should have the same semantics as the original query.  I don't
believe PG knows how to do a rewrite like this at the moment.

-- 
  Sam  http://samason.me.uk/

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to