Re: how to implement selectivity injection in postgresql - Mailing list pgsql-hackers

From Jeff Janes
Subject Re: how to implement selectivity injection in postgresql
Date
Msg-id CAMkU=1wYryU1R51u4wZBimH3K90q3NSrugUw2Xka1DOcqwVb5g@mail.gmail.com
Whole thread Raw
In response to how to implement selectivity injection in postgresql  (Rajmohan C <csrajmohan@gmail.com>)
Responses Re: how to implement selectivity injection in postgresql
List pgsql-hackers
On Wed, Aug 13, 2014 at 9:33 AM, Rajmohan C <csrajmohan@gmail.com> wrote:
SELECT c1, c2, c3, FROM T1, T2, T3        WHERE T1.x = T2.x AND        T2.y=T3.y AND        T1.x >= ? selectivity 0.00001 AND        T2.y > ? selectivity 0.5 AND        T3.z = ? selectivity 0.2 AND        T3.w = ?

I need to implement Selectivity injection as shown in above query in PostgreSQL by which we can inject selectivity of each predicate or at least selectivity at relation level directly as part of query. Is there any on-going work on this front? If there is no ongoing work on this, How should I start implementing this feature?


My plan was to create a boolean operator which always returns true, but estimates its own selectivity as 0.001 (or better yet, parameterize that selectivity estimate, if that is possible) which can be inserted into the place where lower selectivity estimate is needed with an "AND".

And another one that always returns false, but has a selectivity estimate near 1, for use in OR conditions when the opposite change is needed.

I think that will be much easier to do than to extent the grammar.  And probably more acceptable to the core team.  

I think this could be done simply in an extension module without even needing to change the core code, but I never got around to investigating exactly how.

Cheers,

Jeff

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: PostrgeSQL vs oracle doing 1 million sqrts am I doing it wrong?
Next
From: Alvaro Herrera
Date:
Subject: Re: WAL format and API changes (9.5)