Sobes.tech
Middle+

Have you worked with Execution Plan? What metrics do you look at and how do you decide on indexes?

sobes.tech AI

Answer from AI

The Execution Plan shows how the DBMS executes a query and helps optimize it.

Key indicators I pay attention to:

  • Types of operations (Seq Scan, Index Scan, Nested Loop, etc.) — sequential scans are usually slower than index scans.
  • The number of rows processed at each stage — helps identify bottlenecks.
  • Cost — an estimate of the resources needed for execution.

I decide on index solutions if I see:

  • Frequent Seq Scans on large tables where an index on filterable or sortable fields can be added.
  • Unused indexes — they can be removed to save space and speed up inserts.

Example: if a query frequently filters by the "user_id" column and the Execution Plan shows Seq Scan, I add an index:

CREATE INDEX idx_user_id ON table_name(user_id);

Then I check if the Execution Plan has changed and the query now uses an Index Scan.