Optimising Select number of rows in PostgreSql for multiple group by fields
问题 I have this query to get number of rows for the given filters, it takes too long time to get the result since db is too big, is there any way to optimise it i'm using postgresql 8.2 SELECT COUNT(1) as numrows from ( select lower(column1) as column1, column2, column3, column4, sum(column5) as column5, sum(column6) as column6 from table_name tablename where column_date >= 'SOME DATE' and column_date < 'SOME DATE' group by lower(column1) as column1, column2, column3, column4 ORDER BY column5