From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Simple IN vs IN values performace
Date: Mon, 22 Feb 2021 17:45:06 -0600
Message-ID: <7334ed05-d880-d6c5-46ed-24f6b6491a2a@gmail.com> (raw)
In-Reply-To: <F39A0ECE-1FB0-41BA-9429-3C617C51E6A6@uniweb.ua>
References: <F39A0ECE-1FB0-41BA-9429-3C617C51E6A6@uniweb.ua>
On 2/22/21 9:00 AM, Oleksandr Voytsekhovskyy wrote:
> Greetings,
>
> We have queries with IN filters with long list of INT values
>
> Sometimes, they running extremely slow, and I have found suggestion to use
> syntax
> Field IN (VALUES(1465), (1478), ...
> Instead of
> Field IN (1465, 1478, ...
> On some cases it helps, but on other it makes query running 1000+ times slower
Insert the values into a TEMPORARY TABLE, then join that to your main table?
>
> So the issue is:
> - some queries much faster with simple IN
> - some queries much faster with IN + VALUES
>
> Here is explain on case when it’s extremely slow:
>
> -> HashAggregate (cost=5.78..9.62 rows=385 width=4)
> Group Key: ""*VALUES*"".column1"
> -> Values Scan on ""*VALUES*"" (cost=0.00..4.81 rows=385 width=4)"
> What is the right way to pass long INT values list to IN filter?
>
> I am using PostgreSQL 13.1 on Ubuntu
--
Angular momentum makes the world go 'round.
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: ronljohnsonjr@gmail.com
Subject: Re: Simple IN vs IN values performace
In-Reply-To: <7334ed05-d880-d6c5-46ed-24f6b6491a2a@gmail.com>
References: <F39A0ECE-1FB0-41BA-9429-3C617C51E6A6@uniweb.ua> <7334ed05-d880-d6c5-46ed-24f6b6491a2a@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