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 1hkH79-00039s-7V for pgsql-general@arkaria.postgresql.org; Mon, 08 Jul 2019 00:02:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hkH78-00087c-3Q for pgsql-general@arkaria.postgresql.org; Mon, 08 Jul 2019 00:02:38 +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 1hkH77-00084I-JC for pgsql-general@lists.postgresql.org; Mon, 08 Jul 2019 00:02:37 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkH75-0001Wj-2h for pgsql-general@lists.postgresql.org; Mon, 08 Jul 2019 00:02:36 +0000 Received: by mail-pf1-x444.google.com with SMTP id p184so6678723pfp.7 for ; Sun, 07 Jul 2019 17:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=d0fVcXN6ix9VEKtjqORMVwtztMubX6NPD5u7FEFm6Lc=; b=e0ZPeaukufqLhJfSZCFJF/fxSIiUwVoqn6VD5rpkTNG3OFmCVenJlUqaFeLxX5qmVO vk2MC3M4J2vdyb/8s6h9TmBiNmmpD47XbBcU7ze0XG3HYBf4jKZM5EVvoetDmb3/oOou wlKjOoCtaNQCJKu3/spp1BzwSZS2436IHp8w4stJUOneRUUrWc12604r8frEjhPoGRIC qWSnlGJowhGaOc0a751J1orqWecInCVPeJ8/ko5+TJS99M1vh85Xk88sAASup+iR4yuB Vvur/OScgOf95WCzCfGMdq2VjLum4qyacW0jt6Eb7oQ+DIlMP6eB/yDj485T1fzZkt94 p7Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=d0fVcXN6ix9VEKtjqORMVwtztMubX6NPD5u7FEFm6Lc=; b=jnhAWSlZ9DFFncw6fgFnBm0Nl5XD7YmEF1crwi/Oa0R6USv/T+WaeeWGrMWka1XX41 QZnZ8VrLT1vuofy+KcOXN/9e8j42nc2SbFU2LF1o+KGaCrax9nGbzVtMcS9aMDpPE261 vcI3vla/s0fN9MU62er6sS19GhN8NPcyGgiDDEojrBr7wngFs+uIqiN1uZK6gTTkDqNi FTOI/G4JSWpRAfLGCSUZbPe3yDuhEbXmgOGXrIPtGQIIdxmYOA97E0FYU/GtFJNl7N97 vgtCwhEtDwNRS5JhASAfxYqw6wvWrJA5/UapqxFMAPDuoMsl/+d33SPzTGBnwmiVLi8K +jrw== X-Gm-Message-State: APjAAAXnBktJfkd/Dna2uvZeKghnomCoENt6RBimpZpjWpSCk8EQFZQ3 +ogkG0XrpdWJPSthhYSiUW4Zdvft X-Google-Smtp-Source: APXvYqxpm2AtL/eizixLeE4mWpImnQ525zhwE+bwlZqIYdMxzxHQwX3T4eWpK8O8Md1xz1Nq922KjA== X-Received: by 2002:a17:90a:2023:: with SMTP id n32mr20354263pjc.3.1562544154176; Sun, 07 Jul 2019 17:02:34 -0700 (PDT) Received: from [192.168.1.108] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id c130sm15003767pfc.184.2019.07.07.17.02.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Jul 2019 17:02:33 -0700 (PDT) From: Rob Sargent Message-Id: <10CEE386-C195-4864-AF30-7DEE90E9DFF3@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_85E2DBD3-0952-4440-8A3F-1EEB0D320F18" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: Measuring the Query Optimizer Effect: Turning off the QO? Date: Sun, 7 Jul 2019 18:02:33 -0600 In-Reply-To: <9F86AE55-36AC-461C-87C9-34C11C734491@gmail.com> Cc: "pgsql-general@lists.postgresql.org" To: Tom Mercha References: <6E1859C3-4453-4AC2-ABE9-C4F40E5CCDC0@gmail.com> <9F86AE55-36AC-461C-87C9-34C11C734491@gmail.com> X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_85E2DBD3-0952-4440-8A3F-1EEB0D320F18 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Jul 7, 2019, at 6:01 PM, Rob Sargent wrote: >=20 >=20 >=20 >> On Jul 7, 2019, at 5:49 PM, Tom Mercha > wrote: >>=20 >> On 08/07/2019 01:46, Rob Sargent wrote: >>>=20 >>>=20 >>>> On Jul 7, 2019, at 5:22 PM, Tom Mercha > wrote: >>>>=20 >>>> Hi All >>>>=20 >>>> As we know, a query goes through number of stages before it is = executed. >>>> One of these stages is query optimization (QO). >>>>=20 >>>> 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. >>>>=20 >>>> 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 >>>> https://gitlab.com/camplab/jpsgcs = interesting comparisons to perform = with QO tweaks, but right now I >>>> am interested in something basic. >>>>=20 >>>> So how would one shut down QO? Or at least, obtaining the guarantee = of >>>> generating the worst plan possible, ideally without touching many >>>> parameters? >>>>=20 >>>> Best, >>>> Tom >>>=20 >>> Drop all indices? >>>=20 >>=20 >> Sorry, maybe my question wasn't clear enough. >>=20 >> A query can be rewritten in various ways by applying rules and costs = of=20 >> relational algebra operators, as well as their parallelisation. I am=20= >> talking about turning off this query optimization, so I am already=20 >> assuming that indexes aren't present. >=20 > Have you played with any of these settings? >=20 > postgres=3D# select version(); > version = =20 > = --------------------------------------------------------------------------= ------------------------------- > PostgreSQL 10.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 = 20150623 (Red Hat 4.8.5-36), 64-bit > (1 row) >=20 > postgres=3D# select name, setting, unit,short_desc from pg_settings = where name ~ 'para'; > name | setting | unit | = short_desc = =20 > = ---------------------------------+---------+------+-----------------------= --------------------------------------------------------------------------= --- > force_parallel_mode | off | | Forces use of = parallel query facilities. > max_parallel_workers | 16 | | Sets the maximum = number of parallel workers that can be active at one time. > max_parallel_workers_per_gather | 8 | | Sets the maximum = number of parallel processes per executor node. > min_parallel_index_scan_size | 64 | 8kB | Sets the minimum = amount of index data for a parallel scan. > min_parallel_table_scan_size | 1024 | 8kB | Sets the minimum = amount of table data for a parallel scan. > parallel_setup_cost | 1000 | | Sets the planner's = estimate of the cost of starting up worker processes for parallel query. > parallel_tuple_cost | 0.1 | | Sets the planner's = estimate of the cost of passing each tuple (row) from worker to master = backend. > ssl_dh_params_file | | | Location of the = SSL DH parameters file. > (8 rows) >=20 Well not the last one of course.= --Apple-Mail=_85E2DBD3-0952-4440-8A3F-1EEB0D320F18 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii

On Jul 7, 2019, at 6:01 PM, Rob Sargent <robjsargent@gmail.com> wrote:



On Jul = 7, 2019, at 5:49 PM, Tom Mercha <mercha_t@hotmail.com> 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
https://gitlab.com/camplab/jpsgcs 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.

Have you played with any of these settings?

postgres=3D# select version();
   =                     =                     =       version            =                     =                 =  
----------------------------------------------------= -----------------------------------------------------
 PostgreSQL = 10.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red = Hat 4.8.5-36), 64-bit
(1 row)

postgres=3D# select name, setting, unit,short_desc = from pg_settings where name ~ 'para';
    =           name         =       | setting | unit |         =                     =                 short_desc  =                     =                     =    
---------------------------------+---------+------+-= --------------------------------------------------------------------------= -------------------------
 force_parallel_mode       =       | off     |      | Forces = use of parallel query facilities.
 max_parallel_workers      =       | 16      |      | = Sets the maximum number of parallel workers that can be active at one = time.
 max_parallel_workers_per_gather | 8   =     |      | Sets the maximum number of = parallel processes per executor node.
 min_parallel_index_scan_size    | = 64      | 8kB  | Sets the minimum amount of index = data for a parallel scan.
 min_parallel_table_scan_size    | = 1024    | 8kB  | Sets the minimum amount of table data = for a parallel scan.
 parallel_setup_cost       =       | 1000    |      | Sets = the planner's estimate of the cost of starting up worker processes for = parallel query.
 parallel_tuple_cost       =       | 0.1     |      | Sets = the planner's estimate of the cost of passing each tuple (row) from = worker to master backend.
 ssl_dh_params_file      =         |         |    =   | Location of the SSL DH parameters file.
(8 = rows)

Well not = the last one of course.= --Apple-Mail=_85E2DBD3-0952-4440-8A3F-1EEB0D320F18--