GIN Expression Indexes

From: Taylor Sarrafian <taylor(at)pex(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: GIN Expression Indexes
Date: 2020-04-28 20:58:23
Message-ID: AE32DDE9-865F-4DD3-9F8C-9B0CAAABA7AC@pex.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi friends!

We tried to index an array function like this:

CREATE INDEX my_arr_index ON my_table USING GIN ( my_arr_func( my_col ) )

But the planner can’t seem to figure out how to use the index with any query! It doesn’t work with any array operators.

SELECT * FROM my_table WHERE ARRAY[ 123 ]::INT[] && my_arr_func( my_col )

Even weirder, an empty array correctly uses the index:

SELECT * FROM my_table WHERE ARRAY[]::INT[] && my_arr_func( my_col )

Is there any way to coerce Postgres into using this index? Thanks!

ts

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2020-04-29 00:29:01 Re: GIN Expression Indexes
Previous Message Matthias Apitz 2020-04-28 08:10:18 Re: PostgreSQL client hangs sometimes on 'EXEC SQL PREPARE sid_sisisinst FROM :select_anw;'