SELECT col1, max(date) as max_date
FROM table
WHERE col1 ILIKE 'name'
GROUP BY col1
Here col1 is varchar
and date is timestamp with time zone
data type. So created extension CREATE EXTENSION pg_trgm
Then tried the following indexes and got the errors:
1: Issue: ERROR: operator class "gin_trgm_ops" does not accept data type timestamp with time zone
CREATE INDEX CONCURRENTLY trgm_table_col1_date_index
ON table
USING gin (provider_id, date gin_trgm_ops);
2: Issue: ERROR: operator class "text_pattern_ops" does not exist for access method "gin"
CREATE INDEX CONCURRENTLY trgm_table_col1_date_index
ON table
USING gin (provider_id, date text_pattern_ops);
How can I create an index for the above query for faster execution? Any help will be really appreciated!
EDIT: So this works syntactically but does not speed up the query:
CREATE INDEX CONCURRENTLY trgm_provider_date_index
ON table
USING gin (provider_id gin_trgm_ops, date_var)