- Don't use the same server as your production system
- Upgrade to pg 12+ (or avoid common table expressions in your queries)
- Go easy on indexes – less is more
- Consider partitioning long tables
- Ensure you're not I/O-bound
- Vacuum analyze after bulk insertion
- Explore parallel queries
- Increase statistics sampling
- Use fewer columns on frequently-queried tables
- At scale, consider a dedicated warehouse