Anyway to index array with other columns

From: Chris Hoover <chrish(at)aweber(dot)com>
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Anyway to index array with other columns
Date: 2023-08-02 20:17:57
Message-ID: C17CF1E6-B89A-4BBF-8821-11E559B523D9@aweber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I think the answer is no, but I wanted to ask to be sure.

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.

Thanks for any ideas.

Thanks,

Chris Hoover
Senior DBA
AWeber.com
Cell: (803) 528-2269
Email: chrish(at)aweber(dot)com

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message David G. Johnston 2023-08-02 20:24:24 Re: Anyway to index array with other columns
Previous Message David G. Johnston 2023-08-02 16:50:41 Re: Assign User Defined DataType To Columns