From: Vitaliy Garnashevich <vgarnashevich@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: Tricking the optimizer
Date: Thu, 19 Apr 2018 00:06:17 +0300
Message-ID: <18bb3d30-a96c-f91b-3e42-45bb3527dd64@gmail.com> (raw)
In-Reply-To: <2a11d6ec-837e-5284-38cf-efedc52dbbd2@gmail.com>
References: <612dae0f-16b3-e5f8-7458-1ec38aea163c@gmail.com>
<28215.1524059471@sss.pgh.pa.us>
<2a11d6ec-837e-5284-38cf-efedc52dbbd2@gmail.com>
We've tried to use "... WHERE coalesce(...)::bool;" on a test query:
Before:
-> Seq Scan on public.sys_user sys_user_1 (cost=0.00..27140.46 rows=1
width=16) (actual time=0.105..38.627 rows=3289 loops=1)
Filter: (((SubPlan 7) = 0) AND ((SubPlan 8) = 0) AND ((SubPlan 9)
= 0))
After:
-> Seq Scan on public.sys_user sys_user_1 (cost=0.00..27140.46
rows=1790 width=16) (actual time=0.136..28.413 rows=3289 loops=1)
Filter: COALESCE((((SubPlan 7) = 0) AND ((SubPlan 8) = 0) AND
((SubPlan 9) = 0)))
The estimate got closer to the actual number of rows.
Regards,
Vitaliy
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: vgarnashevich@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: Tricking the optimizer
In-Reply-To: <18bb3d30-a96c-f91b-3e42-45bb3527dd64@gmail.com>
References: <612dae0f-16b3-e5f8-7458-1ec38aea163c@gmail.com> <28215.1524059471@sss.pgh.pa.us> <2a11d6ec-837e-5284-38cf-efedc52dbbd2@gmail.com> <18bb3d30-a96c-f91b-3e42-45bb3527dd64@gmail.com>
* 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