When a human writes SQL, a reviewer can rewrite a bad statement. When an agent writes SQL, the statement does not exist until runtime, so the only place you can guarantee selective predicates is the interface the model is forced to speak through. The planner picks a sequential scan whenever it estimates no usable restriction on an indexed column, or when the constant covers too large a slice of the table, as documented for MySQL's optimizer. Postgres behaves the same way: a WHERE name = ... against an unindexed text column produced a parallel sequential scan over roughly 560,000 rows in the Crunchy Data walkthrough of EXPLAIN.
That gives you the design rule. You cannot control the shape of every statement, but you can control the arguments. If the tool only accepts tenant_id plus a bounded date range, the agent physically cannot produce a query without a leading predicate. Index design follows the same logic: start from the access pattern, then put equality columns first and the range or sort column last, which is the leftmost prefix rule described in this composite index analysis. For an orders table that means an index on (tenant_id, created_at), and a tool whose schema requires both fields.
The payoff is large and measurable. In the issue tracker demo, adding a composite index moved a filtered, sorted query from a 16.6ms sequential scan to a 0.04ms index scan because all three conditions landed in the Index Cond and the sort disappeared. You want agent traffic to hit that second plan every time, not sometimes.



