Learning Objectives

By the end of this chapter, you will be able to:

  • Write window functions that rank, compare, and aggregate rows without collapsing your result set
  • Understand the difference between ROWS and RANGE frame modes and know exactly when each one changes your results
  • Write both non-recursive and recursive CTEs, including safe traversal of hierarchical and graph data
  • Read a PostgreSQL query plan produced by EXPLAIN ANALYZE and identify the specific operation causing a slow query
  • Decide when an index will help a query and when it will silently make writes slower for