Thread: Inspecting generated PlannerInfo

Inspecting generated PlannerInfo

From
Fábio Moreira
Date:
Hi everyone,

I wanted to dig around the query planner (specifically, to convert sub-SELECTs in WHERE to LEFT OUTER JOINs — I’m looking into modifying pull_up_sublinks() for that).

From what I could find, PostgreSQL’s tests check for output correctness but not if the query planner is actually applying specific optimizations to the input query; is that correct? Is there any way of serializing a PlannerInfo struct to inspect whether my function is applying the transformations I expect it to?

(I understand, of course, that any optimizations should eventually be visible through EXPLAIN SELECT, but that’s less than ideal for development, as the PlannerInfo will probably also get altered by other optimizations in the way to the client.)

Thanks,

--
Fábio Dias Moreira

Re: Inspecting generated PlannerInfo

From
Tom Lane
Date:
=?UTF-8?Q?F=C3=A1bio_Moreira?= <fabio@dias.moreira.nom.br> writes:
> From what I could find, PostgreSQL’s tests check for output correctness but
> not if the query planner is actually applying specific optimizations to the
> input query; is that correct?

There are quite a few regression tests that look at EXPLAIN output to
verify that particular optimizations happen (or not) as intended.
There's no user-facing mechanism other than that.  For development
purposes, you could consider inserting pprint() calls on Paths at
critical points, or just invoking pprint manually from gdb --- the latter
is what I usually do.

            regards, tom lane