1CREATE INDEX ON test (date_trunc('day', updated_at));
2
3/*If updated_at is a timestamp without time zone, that will work fine.
4For a timestamp with time zone, you'll have to specify a time zone,
5because otherwise the result will depend on the session time zone,
6which makes it unusable for an index:*/
7
8CREATE INDEX ON test (date_trunc('day', updated_at AT TIME ZONE 'UTC'));