Can PostgreSQL index array columns?

I can’t find a definite answer to this question in the documentation. If a column is an array type, will all the entered values be individually indexed?

I created a simple table with one int[] column, and put a unique index on it. I noticed that I couldn’t add the same array of ints, which leads me to believe the index is a composite of the array items, not an index of each item.

INSERT INTO "Test"."Test" VALUES ('{10, 15, 20}');
INSERT INTO "Test"."Test" VALUES ('{10, 20, 30}');

SELECT * FROM "Test"."Test" WHERE 20 = ANY ("Column1");

Is the index helping this query?

3 Answers
3

Leave a Comment