Performance Tips

That wraps up the discussion of performance in PostgreSQL. Here are few tips that you should keep in mind whenever you run into an apparent performance problem:

  • VACUUM and ANALYZE your database after any large change in data values. This will give the query optimizer a better idea of how your data is distributed.

  • Use the CREATE TABLE AS or CLUSTER commands to cluster rows with similar key values. This makes an index traversal much faster.

  • If you think you have a performance problem, use the EXPLAIN command to find out how PostgreSQL has decided to execute your query.

  • You can influence the optimizer by disabling certain query operators. For example, if you want to ensure that a query is executed as a sequential scan, you can disable ...

Get PostgreSQL, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.