Planning without reason.

From: Tzahi Fadida <Tzahi(dot)ML(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Planning without reason.
Date: 2006-06-23 12:57:19
Message-ID: 200606231557.20322.Tzahi.ML@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
I think there is a bug/misscalculation of some rare query i am using.

Suppose we only query one specific relation R.

R contains indices but not on all attributes or not on
all ordered subset of keys.

Query example:
(SELECT * FROM R
WHERE a=3, b=6,. ...)
UNION
(SELECT * FROM R
WHERE b=5, d=2,. ...)
UNION
....
And lots of unions.

When doing explain analyze i see that some nodes in the plan uses an index
and some uses a sequential scan (where the WHERE clause made it impossible
to use an index).
As you can see, having even one sequential scan should nullify the whole plan
to using only one node of sequential scan.
Currently, the planner does not seem to understand that.
I circumvent the problem by doing a recursive tree search of the plan
and checking if there is a node of sequential scan (and redefine the query
as a sequential scan) but obviously it is prefferable that the planner will do
this.

P.s.:
I am currently just writing the query as a string and open a cursor.
Is there a simple way to use Datums instead of converting the attributes to
strings to create a plan for SPI.
10x.

--
Regards,
        Tzahi.
--
Tzahi Fadida
Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info
WARNING TO SPAMMERS:  see at
http://members.lycos.co.uk/my2nis/spamwarning.html

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Csaba Nagy 2006-06-23 12:57:49 Re: vacuum, performance, and MVCC
Previous Message Zeugswetter Andreas DCP SD 2006-06-23 12:41:09 Re: vacuum, performance, and MVCC