I am working on implementing Selectivity hints feature in PostgreSQL 9.3.4. I am working on this only for using it in my academic research. I have decided to give selectivity information per relation as part of query like shown below.
select * from lineitem, orders where l_extendedprice <=2400 and l_orderkey = o_orderkey selectivity(lineitem, 0.3) selectivity(orders, 0.7);
I tried separating the selectivity hint portion of the query before Postgres parses query. But it becomes very clumsy. I am thinking Postgres parser modification to handle this case could be complex that is why I did not get into Postgres grammar and parser. How should I take this selectivity hints separate from a normal query and populate in my data structures?