Re: Look at all paths?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris Cleveland <ccleve+github(at)dieselpoint(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Look at all paths?
Date: 2021-12-29 00:18:20
Message-ID: 1945946.1640737100@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chris Cleveland <ccleve+github(at)dieselpoint(dot)com> writes:
> I'm developing a new index access method. Sometimes the planner uses it and
> sometimes it doesn't. I'm trying to debug the process to understand why the
> index does or doesn't get picked up.

> Is there a way to dump all of the query plans that the planner considered,
> along with information on why they were rejected? EXPLAIN only gives info
> on the plan that was actually selected.

What you can do is "set enable_seqscan = off", then EXPLAIN.
If you get an indexscan where before you did not, then you have
a costing problem, ie use of index is estimated as more costly
than a seqscan. (This is not necessarily wrong, particularly
if you make the rookie mistake of testing with a tiny table.)
If you still get a seqscan, then the planner doesn't think the
query conditions match the index, and you have a different
problem to solve.

If you really want to see all the paths, you could do it with
gdb --- set a breakpoint at add_path and inspect the structs
that get passed to it. I doubt that will give you much
additional info for this problem. However, if (as seems
likely) it's a costing problem, then you may well end up
stepping through your amcostestimate function to see where
it's going off the rails; so learning to gdb the backend
will be well worth your time anyway.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-12-29 01:20:53 Re: add recovery, backup, archive, streaming etc. activity messages to server logs along with ps display
Previous Message Chris Cleveland 2021-12-29 00:07:50 Look at all paths?