From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Chris Hoover <chrish@aweber.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: Anyway to index array with other columns
Date: Thu, 03 Aug 2023 08:30:44 +0200
Message-ID: <c33f14e7990deba1020eaf568cf6c1182d3e63b3.camel@cybertec.at> (raw)
In-Reply-To: <C17CF1E6-B89A-4BBF-8821-11E559B523D9@aweber.com>
References: <C17CF1E6-B89A-4BBF-8821-11E559B523D9@aweber.com>
On Wed, 2023-08-02 at 16:17 -0400, Chris Hoover wrote:
> Given table below, is there any way to index field_a, field_b, array_a?
>
> Create table table1 (
> field_a integer not null primary key,
> field_b integer not null,
> ...
> array_a text[]
> )
>
> My app is running queries similar to this:
> Select * from table1 where field_a = 123 and field_b = 456 and array_a @> ARRAY[’tag_xyz’];
>
> The array_a can have unto 1000 elements. Currently these queries get very expensive if the array has any length to it.
That seems unlikely, since you have the primary key in the WHERE condition.
Can you provide the output of EXPLAIN (ANALYZE, BUFFERS, VERBOSE)
for the query?
Yours,
Laurenz Albe
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 using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: laurenz.albe@cybertec.at, chrish@aweber.com, pgsql-admin@lists.postgresql.org
Subject: Re: Anyway to index array with other columns
In-Reply-To: <c33f14e7990deba1020eaf568cf6c1182d3e63b3.camel@cybertec.at>
* 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