pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
GIN Expression Indexes 2+ messages / 2 participants [nested] [flat]
* GIN Expression Indexes @ 2020-04-28 20:58 Taylor Sarrafian <taylor@pex.com> 0 siblings, 1 reply; 2+ messages in thread From: Taylor Sarrafian @ 2020-04-28 20:58 UTC (permalink / raw) To: 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= ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: GIN Expression Indexes @ 2020-04-29 00:29 Adrian Klaver <adrian.klaver@aklaver.com> parent: Taylor Sarrafian <taylor@pex.com> 0 siblings, 0 replies; 2+ messages in thread From: Adrian Klaver @ 2020-04-29 00:29 UTC (permalink / raw) To: Taylor Sarrafian <taylor@pex.com>; pgsql-general On 4/28/20 1:58 PM, Taylor Sarrafian wrote: > 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! Well without: 1) Table schema. 2) EXPLAIN ANALYZE for the query(s) there is really not information to formulate an answer. > > ts -- Adrian Klaver adrian.klaver@aklaver.com ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2020-04-29 00:29 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-04-28 20:58 GIN Expression Indexes Taylor Sarrafian <taylor@pex.com> 2020-04-29 00:29 ` Adrian Klaver <adrian.klaver@aklaver.com>
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