Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkHhQ-0004Oy-RU for pgsql-general@arkaria.postgresql.org; Mon, 08 Jul 2019 00:40:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hkHgR-0005Od-NN for pgsql-general@arkaria.postgresql.org; Mon, 08 Jul 2019 00:39:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkHgR-0005Ja-Aa for pgsql-general@lists.postgresql.org; Mon, 08 Jul 2019 00:39:07 +0000 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkHgO-0001vt-TA for pgsql-general@lists.postgresql.org; Mon, 08 Jul 2019 00:39:06 +0000 Received: by mail-ot1-x342.google.com with SMTP id e8so14436510otl.7 for ; Sun, 07 Jul 2019 17:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=+1ifxbE0o5yN8fO0WY1UkxAjPF8nz4esR/+WPwIOnRs=; b=obY6Dv9iDTbtzh2EL8g986mJyDQNHX5aCUoPYeNpJGdQL/wlkjLdeuGT6eVWFpo/fU rg9kga2zkzfqZlRfRu1kwmSrxf2LGKjZCvImx6T1QtaZkoWzP1EJrgg5hnHzOjuueQ/p wAANtljXAioWBhFoxh+XSXd45vrTCBH9LOctjdoQDARHU/MuE9vRYXl9gykh5oPJGOWm zldl+pZA6Vjk2wFOfU4GtB8YshvX1tMCG2xgLMIvpZwHqaWubZs2CnmQagfSst60wM5t 9SOR02X8YysLNWSqf5QHHEnMAvkDgaGG2Y3zijEW+DiYiMT4jDFh67Cvo+wjfEALauFn LGuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=+1ifxbE0o5yN8fO0WY1UkxAjPF8nz4esR/+WPwIOnRs=; b=s890hBtSNrM2AnpPxD3Rk6+uFH8CIwHpwtO6kyFP5rYZRcaxdp5HYpY/hYzQneE1Kx iZwtCRvR3Ozwtqfk4tKXg3wE3+Zx30EWrWcbXAqrxYVzz3exiAM2T3ktQZNo3VVd1269 9BXGCrFvKdWsKoBa/tmAgq3HGr9c3yjxZrMaElpIYCRieErd1046gs8Qb0CWZekzKy6J u2ANUVjMZwSSUaZ+z2gpWYo2axuqFS+pEUeXIJ74zBzt5fcCaZWz2DhOQSL3RyI6vNBg fLQkzYQCAq811TBUpuStD2KXbmpirpENRDSpOPBfIHMfeTnJjv6/Xd6zF9Nd1giBDYJB o6wQ== X-Gm-Message-State: APjAAAVIvwgwzoGZ8gnT8HPL9u5/A1/fFC8ldt311AJqX4FUIGkC7k6N 2m/teWQvUFUwMalPCgmpToxBbim3vRsgCQ== X-Google-Smtp-Source: APXvYqxGGhqzwK37w6hAvGeYSGiBLbYKMwY894uaf/ToWWGz2mL7thckssSBB7FW9AAaCrL8YNzTuw== X-Received: by 2002:a9d:6059:: with SMTP id v25mr8153719otj.90.1562546344134; Sun, 07 Jul 2019 17:39:04 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id e10sm5059160oie.37.2019.07.07.17.39.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Jul 2019 17:39:03 -0700 (PDT) Subject: Re: Measuring the Query Optimizer Effect: Turning off the QO? To: pgsql-general@lists.postgresql.org References: <6E1859C3-4453-4AC2-ABE9-C4F40E5CCDC0@gmail.com> From: Ron Message-ID: <08b1ba25-f21d-96ec-1ed8-8315d3190945@gmail.com> Date: Sun, 7 Jul 2019 19:39:02 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------19F930E5F3860B781792E2E8" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------19F930E5F3860B781792E2E8 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 7/7/19 6:49 PM, Tom Mercha wrote: > On 08/07/2019 01:46, Rob Sargent wrote: >>> On Jul 7, 2019, at 5:22 PM, Tom Mercha wrote: >>> >>> Hi All >>> >>> 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. >>> >>> Obviously, I know well what the results would generally look like but I >>> am just interested in measuring the differences for various types of >>> queries. I am also aware that this is a simple comparison - there are >>> more interesting comparisons to perform with QO tweaks, but right now I >>> am interested in something basic. >>> >>> So how would one shut down QO? Or at least, obtaining the guarantee of >>> generating the worst plan possible, ideally without touching many >>> parameters? >>> >>> Best, >>> Tom >> Drop all indices? >> > Sorry, maybe my question wasn't clear enough. > > A query can be rewritten in various ways by applying rules and costs of > relational algebra operators, as well as their parallelisation. I am > talking about turning off this query optimization, so I am already > assuming that indexes aren't present. It seems as though you're asking what the "First Approximation" plan is, before it tries to get Too Clever.  However, I don't think there's a separation between Query *Planner* and Query *Optimizer*. https://www.postgresql.org/docs/9.6/planner-optimizer.html -- Angular momentum makes the world go 'round. --------------19F930E5F3860B781792E2E8 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 7/7/19 6:49 PM, Tom Mercha wrote:
On 08/07/2019 01:46, Rob Sargent wrote:
On Jul 7, 2019, at 5:22 PM, Tom Mercha <mercha_t@hotmail.com> wrote:

Hi All

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.

Obviously, I know well what the results would generally look like but I
am just interested in measuring the differences for various types of
queries. I am also aware that this is a simple comparison - there are
more interesting comparisons to perform with QO tweaks, but right now I
am interested in something basic.

So how would one shut down QO? Or at least, obtaining the guarantee of
generating the worst plan possible, ideally without touching many
parameters?

Best,
Tom
Drop all indices?

Sorry, maybe my question wasn't clear enough.

A query can be rewritten in various ways by applying rules and costs of 
relational algebra operators, as well as their parallelisation. I am 
talking about turning off this query optimization, so I am already 
assuming that indexes aren't present.

It seems as though you're asking what the "First Approximation" plan is, before it tries to get Too Clever.  However, I don't think there's a separation between Query Planner and Query Optimizer.  https://www.postgresql.org/docs/9.6/planner-optimizer.html

--
Angular momentum makes the world go 'round.
--------------19F930E5F3860B781792E2E8--