From: Tom Lane <tgl@sss.pgh.pa.us>
To: Danny Shemesh <dany74q@gmail.com>
Cc: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: pgsql-general@postgresql.org
Subject: Re: Index filter instead of index condition w/ IN / ANY queries above certain set size
Date: Wed, 23 Nov 2022 09:29:19 -0500
Message-ID: <3695029.1669213759@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFZC=QrNdG+6+K1tWyZTRtiAz6+VG_8hQrnhTYV-Dac2eFaanQ@mail.gmail.com>
References: <CAFZC=QoOTo4gYBA-gDz-XJejfBZVfgy3VZV7zpQc6T4C+3Yf+g@mail.gmail.com>
<df2e15e9b4d5d72ce2e6a6dc65eb8dc529cee8d8.camel@cybertec.at>
<CAFZC=QrNdG+6+K1tWyZTRtiAz6+VG_8hQrnhTYV-Dac2eFaanQ@mail.gmail.com>
Danny Shemesh <dany74q@gmail.com> writes:
> -> Index Only Scan using
> idx_hashes on refs (cost=0.56..722735.47 rows=33715 width=16) (actual
> time=1727.208..1727.208 rows=1 loops=1)
> Index Cond: (tid =
> '13371337-1337-1337-1337-133713371337'::uuid)
> * Filter: (tidh = ANY
> ('{13391339-1339-1339-1339-133913391339}'::uuid[])) <<<<<<<<<<<<<<<-
> Note this line* Rows Removed
> by Filter: 109087
> Heap Fetches: 16976
> Buffers: shared hit=13051
> read=14561
> I/O Timings: read=53405.294
This doesn't match up terribly well with the table definition
you showed before, but I wonder whether tidh is a low-order
index column. If you need to optimize this specific shape
of query you need to pay attention to the index column order, per
https://www.postgresql.org/docs/current/indexes-multicolumn.html
That is, tid and tidh need to be the first two index columns.
regards, tom lane
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: tgl@sss.pgh.pa.us, dany74q@gmail.com, laurenz.albe@cybertec.at
Subject: Re: Index filter instead of index condition w/ IN / ANY queries above certain set size
In-Reply-To: <3695029.1669213759@sss.pgh.pa.us>
References: <CAFZC=QoOTo4gYBA-gDz-XJejfBZVfgy3VZV7zpQc6T4C+3Yf+g@mail.gmail.com> <df2e15e9b4d5d72ce2e6a6dc65eb8dc529cee8d8.camel@cybertec.at> <CAFZC=QrNdG+6+K1tWyZTRtiAz6+VG_8hQrnhTYV-Dac2eFaanQ@mail.gmail.com> <3695029.1669213759@sss.pgh.pa.us>
* 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