Postgresql 中文操作指南

11.12. Examining Index Usage #

尽管 PostgreSQL 中的索引不需要维护或调整,但检查哪些索引实际上被实际查询工作负载使用仍然很重要。使用 EXPLAIN 命令检查单个查询的索引使用情况;其应用场景在 Section 14.1 中进行了说明。也可以收集正在运行的服务器中索引使用情况的总体统计信息,如 Section 28.2 中所述。

Although indexes in PostgreSQL do not need maintenance or tuning, it is still important to check which indexes are actually used by the real-life query workload. Examining index usage for an individual query is done with the EXPLAIN command; its application for this purpose is illustrated in Section 14.1. It is also possible to gather overall statistics about index usage in a running server, as described in Section 28.2.

很难制定一个通用过程来确定要创建哪些索引。前面各节中示例中展示了许多典型情况。经常需要进行大量的实验。本节的其余部分提供了一些提示:

It is difficult to formulate a general procedure for determining which indexes to create. There are a number of typical cases that have been shown in the examples throughout the previous sections. A good deal of experimentation is often necessary. The rest of this section gives some tips for that: