PostgreSQL: Create an index on timestamp::DATE [duplicate]
问题 This question already has answers here : PostgreSQL: Index the day part of a timestamp (2 answers) Closed 4 years ago . I am creating a summary table that sums up all events in a given day. INSERT INTO graph_6( day, event_type, (SELECT COUNT(*) FROM event e WHERE event_type = e.event_type AND creation_time::DATE = sq.day) FROM event_type CROSS JOIN (SELECT generate_series( (SELECT '2014-01-01'::DATE), (SELECT '2014-01-02'::DATE), '1 day') as day) sq; The creation_time column is indexed: