From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Lukas Smith <smith(at)pooteeweet(dot)org> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Automatic function replanning |
Date: | 2005-12-22 20:53:03 |
Message-ID: | 200512222053.jBMKr3i24745@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Lukas Smith wrote:
> Jim C. Nasby wrote:
>
> > Now, if both of these are done using a prepared statement, it's going to
> > look like:
> >
> > SELECT * FROM queue WHERE status='?';
> >
> > If the first one to run is the queue processing one, the planner will
> > probably choose the index. This means that when we're searching on 'N',
> > there will be a fairly small number of tuples read to execute the query,
> > but when searching for 'D' a very large number of tuples will be read.
>
> I do not know how exactly how pg handles this internally, however while
> skimming the oracle tuning pocket guide I picked up for 2 euros I
> noticed that it mentioned that since oracle 9i bound parameter values
> are evaluated before the execution plan is determined.
>
> Maybe I am mixing up separate concepts (are bound variables and prepared
> statements different concepts?) here. I also do not really understand if
> that means that oracle does not store a query plan for a prepared query
> or if it just does some special handling in case it knows that a
> prepared statement column is known to have a highly varying selectivity
> per value.
What the Oralce manual means I think is that the plan of the query is
delayed until the _first_ EXECUTE, so it has some values to use in the
optimizer. The problem is that later queries might use constants of
greatly different cardinality.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Lukas Smith | 2005-12-22 20:55:14 | Re: Automatic function replanning |
Previous Message | Lukas Smith | 2005-12-22 20:48:51 | Re: Automatic function replanning |