You often make sums. Why not use separate tables to cache these sums by month, by poste, by whatever ?
Rule on insert on the big table updates the cache tables.
---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match