I'd like to create GIN index on a scalar text column using an ARRAY[] expression like so:
CREATE TABLE mytab (
scalar_column TEXT
)
CREATE INDEX idx_gin ON mytab USING GIN(ARRAY[scalar_column]);
Postgres reports an error on ARRAY keyword.
I'll use this index later in a query like so:
SELECT * FROM mytab WHERE ARRAY[scalar_column] <@ ARRAY['some', 'other', 'values'];
How do I create such an index?
scalar_columnmatches one of a list of values? If so, you can just use a regular btree index and filterWHERE scalar_column IN ('some', 'other', 'values')CREATE INDEX idx_gin ON mytab USING GIN(string_to_array(scalar_column, ''));I wonder if there is a proper way to create such an index.<@operator with GIN index is faster than= ANYoperator with no index. How would you speed up queries which check value against a given array?