There are several aspects of optimizing database performance, such as hardware configuration, network settings, database configuration, rewriting SQL queries, and maintaining indexes. In this chapter, we'll focus only on basic configuration and rewriting queries.
Generally speaking, tuning database performance requires knowledge about the system's nature; for example, we need to know whether the database system can be used for online analytical processing (OLAP) or online transactional processing (OLTP). The database system may be IO- or CPU-bound; these define the whole database cluster setup, such as the number of CPUs, CPU power, RAID configuration, amount of RAM, and the database cluster's configuration. Once the database server is configured, you could use a benchmark framework, such as pgbench, to calculate the number of transactions...