In this chapter, we will cover the following recipes:
Finding slow SQL statements
Collecting regular statistics from
pg_stat*
viewsFinding out what makes SQL slow
Reducing the number of rows returned
Simplifying complex SQL queries
Speeding up queries without rewriting them
Why a query is not using an index
Forcing a query to use an index
Using optimistic locking
Reporting performance problems