Showing alternative query planner plans with explain ?

From: Danny Shemesh <dany74q(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Showing alternative query planner plans with explain ?
Date: 2022-05-29 11:49:48
Message-ID: CAFZC=QpMZutOUnJATYzLiuvM9CAk7UPpWmnZX6uGXxgHYSE6nw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey all !

I'm currently optimizing queries and indices on a relatively large dataset;
one of the frequent questions I seem to ask myself is why the planner
chooses plan A over B.

Reading the docs, blogs, stack exchange posts, wiki, ... helps in trying to
tinker with the query or indices in a way that either A will be
discouraged, or B will be favoured, so I'd be more informed on why one was
chosen over the other and which is empirically better for a given dataset.

A tool I seem to be missing, and I wondered if such exists, is to have the
planner output alternative plans for a given query, i.e. to say, give me
the x top plans sorted by cost - I believe this would help shed some light
on the internal state machine and subsequent tinkering less
trial-and-error-ish.

Is there any way to achieve the above ?

Thanks a ton,
Danny

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2022-05-29 14:44:59 Re: Showing alternative query planner plans with explain ?
Previous Message Noah Misch 2022-05-29 04:34:03 Re: Extension pg_trgm, permissions and pg_dump order