pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tom Mercha <mercha_t@hotmail.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Measuring the Query Optimizer Effect: Turning off the QO?
Date: Sun, 07 Jul 2019 21:26:44 -0400
Message-ID: <20762.1562549204@sss.pgh.pa.us> (raw)
In-Reply-To: <AM6PR04MB5544CCC486DA6B21968A1217F4F70@AM6PR04MB5544.eurprd04.prod.outlook.com>
References: <AM6PR04MB5544CCC486DA6B21968A1217F4F70@AM6PR04MB5544.eurprd04.prod.outlook.com>

Tom Mercha <mercha_t@hotmail.com> writes:
> As we know, a query goes through number of stages before it is executed. 
> One of these stages is query optimization (QO).
> There are various parameters to try and influence optimizer decisions 
> and costs. But I wanted to measure the effect of such a stage by turning 
> it off completely and I can't find such a parameter which explicitly 
> does that. Then I could execute a query to get the effect of "QO active 
> and "QO inactive" and compare.

There is no such parameter because the code can't support that.  For
efficiency reasons, query optimization is bound up pretty tightly with
essential plan-preparation activities.  As an example, you can't turn
off constant-folding because eval_const_expressions also takes care of
some non-optional activities like filling in default parameter values
in function calls.

However, there are some knobs you can twiddle, as others have already
pointed out.  Two I'd particularly draw your attention to are
join_collapse_limit and from_collapse_limit --- if you set both to 1,
that'll effectively disable searching for a good join order, causing
the join order to match the syntactic structure of the FROM clause.
For instance "FROM a,b,c" will always be done by joining a to b first
then joining to c.  The code will still consider all possible ways
to do each of those joins, though you can shut off consideration of
some possibilities with parameters like enable_hashjoin.

			regards, tom lane





view thread (16+ messages)  latest in thread

Message-ID: <20762.1562549204@sss.pgh.pa.us>
Permalink:  ../20762.1562549204@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20762.1562549204@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mercha_t@hotmail.com
  Subject: Re: Measuring the Query Optimizer Effect: Turning off the QO?
  In-Reply-To: <20762.1562549204@sss.pgh.pa.us>
  References: <AM6PR04MB5544CCC486DA6B21968A1217F4F70@AM6PR04MB5544.eurprd04.prod.outlook.com> <20762.1562549204@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox