Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower
От | David Rowley |
---|---|
Тема | Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower |
Дата | |
Msg-id | CAApHDvqhr1eU9v42w5gt_gL=G15pB9RBpAH_Jmg7eDU6iZ_2zg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower
|
Список | pgsql-bugs |
On Thu, 7 Jul 2022 at 15:07, Tom Lane <tgl@sss.pgh.pa.us> wrote: > While I don't have any problem with tracking column NOT NULL flags > in RelOptInfo once the planner has a use for that info, I'm not sure > that we have a solid use-case for it quite yet. In particular, the > fact that the table column is marked NOT NULL doesn't mean that any > particular occurrence of that column's Var can be freely assumed to be > non-null. The patch I'm working on to label Vars that have possibly > been nulled by outer joins [1] seems like essential infrastructure for > doing anything very useful with the info. I was aware that you'd done that work. I'm interested in it, but just not found the time to look yet. > Maybe that objection doesn't apply to build_minmax_path's usage in > particular, but that's an awfully narrow use-case. I thought I'd quickly put the idea together and fairly quickly noticed that we do preprocess_minmax_aggregates() in grouping_planner(), which is long before we load the RelOptInfo data in add_base_rels_to_query(), which is called in query_planner(). I considered if we could move the preprocess_minmax_aggregates(), but that does not seem right, although, surprisingly, no tests seem to fail from doing so. I'd have expected at least some EXPLAIN outputs to have changed from the no-longer-present IS NOT NULL quals. I imagine a much less narrow case would be to check for redundant RestrictInfos in distribute_restrictinfo_to_rels(). That would also catch cases such as WHERE non_nullable_col IS NULL, provided that qual made it down to baserestrictinfo. When I realised that, I thought I might be starting to overlap with your work in the link below. > [1] https://www.postgresql.org/message-id/flat/830269.1656693747@sss.pgh.pa.us The 2 attached patches do fix the bad reported plan, it's just that it's a very roundabout way of fixing it Anyway, I've no current plans to take the attached any further. I think it'll be better to pursue your NULLable-Var stuff and see if we can do something more generic like remove provably redundant NullTests from baserestrictinfo. David
Вложения
В списке pgsql-bugs по дате отправления: