PostgreSQL query performance bottlenecks
Another postgresql performance gotcha:Find all the coupons that are expired (90 day expiration):    SELECT * FROM coupon
    WHERE created_at + INTERVAL '90 DAY' < now()

This will not use the index on the "created_at" column and will be slow.You should rewrite the inequality to:    SELECT * FROM coupon
    WHERE created_at < now() - INTERVAL '90 DAY'

and now the query will be much faster. There are a lot of cases in postgres where simple equivalent algebraic manipulations can completely change the query plan