Re: join selectivity - Mailing list pgsql-hackers

From Tom Lane
Subject Re: join selectivity
Date
Msg-id 24929.1103212470@sss.pgh.pa.us
Whole thread Raw
In response to Re: join selectivity  ("Mark Cave-Ayland" <m.cave-ayland@webbased.co.uk>)
Responses Re: join selectivity
List pgsql-hackers
"Mark Cave-Ayland" <m.cave-ayland@webbased.co.uk> writes:
> ...and with two indices RESTRICT is called four times. The part I find
> confusing is why with one index that RESTRICT is called twice.

[ shrug... ]  clause_selectivity doesn't try to cache the result.

> I was also thinking whether calling RESTRICT when comparing with an unknown
> value is worth doing at all, however I did think that perhaps if you are
> using a cast to perform an operation on two datatypes, then you may be able
> to imply something from the index, such as its physical size, and hint that
> the planner should use a particular index in preference for the other.

That would be inappropriate; the index size is factored in elsewhere
(gistcostestimate() to be specific).  Restriction selectivity shouldn't
directly consider the existence of indexes at all.

> Would it be correct to assume that if returning the same value for
> RESTRICT for both means that the planner will choose one at random?

If the tables/indexes are exactly the same size then you'd get the same
cost and the choice would be effectively random.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Mark Cave-Ayland"
Date:
Subject: Re: join selectivity
Next
From: "Zeugswetter Andreas DAZ SD"
Date:
Subject: Re: [Testperf-general] BufferSync and bgwriter