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 1hkH6U-00038m-UZ for pgsql-general@arkaria.postgresql.org; Mon, 08 Jul 2019 00:01:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hkH6T-0004R9-Q9 for pgsql-general@arkaria.postgresql.org; Mon, 08 Jul 2019 00:01:57 +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 1hkH6T-0004O0-7G for pgsql-general@lists.postgresql.org; Mon, 08 Jul 2019 00:01:57 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkH6Q-0001Vt-Ke for pgsql-general@lists.postgresql.org; Mon, 08 Jul 2019 00:01:56 +0000 Received: by mail-pl1-x643.google.com with SMTP id c2so5723371plz.13 for ; Sun, 07 Jul 2019 17:01:54 -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=SyviJuyeAS4E2QDEK9+vquPFkB/5zJxOEBGOJIpxMcY=; b=cTg+Y19CzFSz+kPtdRDE8wp6NVArsPbWwvP5R65y62R4rNedSHDgdVamdzBz7uyplU h5OYhWk3laEZZ8VlrRfMWNoz6LPK/YTXH6s5kCC/Cbn6X1yhiYoPuZxKphxMVr+wvzmK A1Wde/UuaoMaHr9QViLT74TB/QCHPv6abTKhpXU9xygr5k8qu3dL2rY63P6f+1OW5XdE 9bebGn6YMYSlkVY4T6l3uPL9O3g+buauB/SJF0vr390NUcLqgeIa4NQyTguEKrdACTyf Nobt31YNZtcxKElXmJCE/kFmwJyRhGrKQPlWH0fGesOXt+NAbxoOpFARxp29hUo+O+dz RcRA== 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=SyviJuyeAS4E2QDEK9+vquPFkB/5zJxOEBGOJIpxMcY=; b=ld0KVuBQVFMyNEi/HBhYXPlZU54OOaLPcQ1EVTD6sx2h4c4Ql9aAkY6/L0CqUtMcMy 3MfOo+AJ7wu+0rsll7T5EE8xaYIJpDmeJELUckMQovU5EjwhO93UP1ZDQmb7H18rTUFj xtFiOKl7qBcyGk/sOasn3jhUiOxILqXd5WZQfh2y0vRc1Dldfgtzm0uG7HzRWxKAE5YC 7WbFRO33SJIxUOCx/denODEGZSicfgzrFw67JBo6TQKLAr8258pQIhS5LE/yg3qTc945 dWVzkM/3c958W5lG1lx//PE1oIlyS8nUpHtVWBKB509hyINrATmF5Br1Lr3AFB5z3iH9 Qe1Q== X-Gm-Message-State: APjAAAXNuCrWInDHBp3M+9pKR0BnlvrSEyFbxEQyGBGSmQ6I7QoS6D7u mnkyQN+XzPlIOk8OOy+zLiM= X-Google-Smtp-Source: APXvYqwwu4YelLaFTuZF9Et+0mJ5M+8qnJAbLqdSHhPOgSlenbZQNPB1/zW7FxmBRBtnYewMUJ2Xvw== X-Received: by 2002:a17:902:6b02:: with SMTP id o2mr19064318plk.99.1562544113581; Sun, 07 Jul 2019 17:01:53 -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.01.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Jul 2019 17:01:53 -0700 (PDT) From: Rob Sargent Message-Id: <9F86AE55-36AC-461C-87C9-34C11C734491@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_A4FF8B0E-1840-4D8E-AA1B-5B3509ACA3B3" 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:01:51 -0600 In-Reply-To: Cc: "pgsql-general@lists.postgresql.org" To: Tom Mercha References: <6E1859C3-4453-4AC2-ABE9-C4F40E5CCDC0@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=_A4FF8B0E-1840-4D8E-AA1B-5B3509ACA3B3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > 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. Have you played with any of these settings? 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) 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) --Apple-Mail=_A4FF8B0E-1840-4D8E-AA1B-5B3509ACA3B3 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii

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)

= --Apple-Mail=_A4FF8B0E-1840-4D8E-AA1B-5B3509ACA3B3--