---
title: "Select only the columns you use · Agent Wranglers"
url: https://agentwranglers.se/playbook/data/queries-and-indexes/select-columns
updated: 2026-10-20
licence: "All rights reserved"
---

# Select only the columns you use

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Queries and indexes](https://agentwranglers.se/playbook/data/queries-and-indexes)
- Rule: Name the columns a query needs. Avoid `SELECT *` in app code.
- How: 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.
- Check: Search the app code for `SELECT *`. It appears only in ad hoc scripts and tests.

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers data playbook: https://agentwranglers.se/playbook/data/queries-and-indexes/select-columns`.

- Previous: [Load related rows in one query](https://agentwranglers.se/playbook/data/queries-and-indexes/no-n-plus-one)
- Next: [Page through long lists by key](https://agentwranglers.se/playbook/data/queries-and-indexes/keyset-pagination)
- [Queries and indexes](https://agentwranglers.se/playbook/data/queries-and-indexes)
