Re: Measuring the Query Optimizer Effect: Turning off the QO? - Mailing list pgsql-general

From Tom Lane
Subject Re: Measuring the Query Optimizer Effect: Turning off the QO?
Date
Msg-id 20762.1562549204@sss.pgh.pa.us
Whole thread Raw
In response to Measuring the Query Optimizer Effect: Turning off the QO?  (Tom Mercha <mercha_t@hotmail.com>)
Responses Re: Measuring the Query Optimizer Effect: Turning off the QO?  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
List pgsql-general
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



pgsql-general by date:

Previous
From: Ron
Date:
Subject: Re: Measuring the Query Optimizer Effect: Turning off the QO?
Next
From: Michael Paquier
Date:
Subject: Re: Active connections are terminated because of smallwal_sender_timeout