Is it possible to create an index on a column with type of text array. Tried using GIN indexes, but queries do not seem to be using those indexes.
-- Example:
CREATE TABLE users (
name VARCHAR(100),
groups TEXT[],
);
-- Query:
SELECT name FROM users WHERE ANY(groups) = 'Engineering';
Also what is the best way to perform GROUP BY on groups column efficiently so that it can give groups and count.
A gin index can be used:
Result:
Using aggregate functions on an array, that will be another problem. The function unnest() might help.
Why don’t you normalize your data? That will fix all problems, including many problems you didn’t encouter yet.