Skip to content
Wade Womersley

wade.one

wade womersley – york based software engineer

  • Home
  • 2026
  • October
  • 15
  • Read the PostgreSQL Query Plan Before Adding Another Index

Read the PostgreSQL Query Plan Before Adding Another Index

Posted on October 15, 2026 By
Programming

When a database query gets slow, adding an index is an appealingly concrete thing to do. I would still look at the query plan first. An index on the wrong column combination can leave the original problem intact while giving every write another bit of maintenance to perform.

PostgreSQL’s EXPLAIN guide shows how the planner expects to execute a query. EXPLAIN ANALYZE adds measurements from actually running it, which is useful but deserves care: it executes the statement, including changes made by write queries. Start with a safe query and representative data rather than casually experimenting against production.

I look for where the work grows: a join producing far more rows than expected, a filter discarding most of what was read, or a sort covering a large result that the application barely uses. A sequential scan is not automatically a mistake. Sometimes reading a small table directly is the sensible plan, and forcing an index would only satisfy a prejudice.

The useful outcome is a measured improvement to the query people run. Compare before and after with the same conditions, and keep the application behaviour intact. “We added three indexes” is an implementation detail. “This screen no longer makes people wait” is the result that matters.

Share:

  • Share on Facebook (Opens in new window) Facebook
  • Share on X (Opens in new window) X
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Reddit (Opens in new window) Reddit

Related

Comments

comments

Tags: performance postgresql sql

Post navigation

❮ Previous Post: An API Timeout Does Not Mean the Operation Failed

You may also like

Programming
PHP FUNdamentals
September 1, 2009
Programming
Linux RAID, MySQL
September 10, 2009
Programming
Another day, another group of PHP “funness”
September 2, 2009
Programming
The Hardest Part of Serverless Is Not the Code
April 12, 2026
  • AI
  • artificial intelligence
  • Ego-centric
  • Events
  • Films
  • Food
  • Gaming
  • Gym
  • Hardware
  • Holidays
  • News
  • PHP
  • Programming
  • Random Stuff
  • Reviews
  • Science
  • SEO
  • Software
  • Software Engineer
  • Support
  • Uncategorized
  • Work

Copyright © 2026 wade.one.

Theme: Oceanly News Dark by ScriptsTown