Adaptive Plan Sharing for PreparedStmt

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Adaptive Plan Sharing for PreparedStmt
Date: 2021-05-20 03:43:39
Message-ID: CAKU4AWr7tOy4X+FB2utnxDNujGkoQcCoNgSUQCKb_c=uh3BefA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Currently we are using a custom/generic strategy to handle the data skew
issue. However, it doesn't work well all the time. For example: SELECT *
FROM t WHERE a between $1 and $2. We assume the selectivity is 0.0025,
But users may provide a large range every time. Per our current strategy,
a generic plan will be chosen, Index scan on A will be chosen. oops..

I think Oracle's Adaptive Cursor sharing should work. First It calculate
the selectivity with the real bind values and generate/reuse different plan
based on the similarity of selectivity. The challenges I can think of now
are:
a). How to define the similarity. b). How to adjust the similarity during
the
real run. for example, we say [1% ~ 10%] is similar. but we find
selectivity 20%
used the same plan as 10%. what should be done here.

I am searching for the best place to invest in the optimizer aspect. and
the above idea should be the one I can think of now. Any thought?

Thanks
--
Best Regards
Andy Fan (https://www.aliyun.com/)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-05-20 04:10:46 Re: Refactor "mutually exclusive options" error reporting code in parse_subscription_options
Previous Message Suraj Kharage 2021-05-20 03:24:56 Re: Query about time zone patterns in to_char