Isak Hansen wrote:
Absolutely brilliant - this solved my issue, brought the query time down to about 2 seconds initially, then about 500 milliseconds thereafter. Thank you very much for this tip.First thing I notice is that your query plans seem to only use one index. Postgres should be able to combine the timestamp and account_id indexes in that first query, if the optimizer thought there was a point in doing so?