Agent Wranglers

DAT-12Recommended

Select only the columns you use

Name the columns a query needs. Avoid SELECT * in app code.

How to do it

Listing columns sends less data and lets the database answer from an index alone. It also stops new columns, such as secrets, from leaking into replies. It also helps you return only the fields needed.

How to check

Search the app code for SELECT *. It appears only in ad hoc scripts and tests.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/data/queries-and-indexes/select-columns">Agent Wranglers data and databases playbook</a>. In code you write, add a comment next to it with the same link.