Querying only the columns you need can significantly reduce processing time and resource use.
Using SELECT *
may seem convenient, but it can have significant performance drawbacks—especially when working with large tables or returning results over the network. When you query all columns, you're asking the database to retrieve, process, and transmit every field—even those that aren’t relevant to your task.
This increases I/O, bloats memory usage, and slows down query execution, particularly in reporting, dashboards, and analytics tools where only a few fields are needed. For example, fetching unnecessary columns like last_login_ip
, profile_photo
, or large JSON blobs can choke a query.
Instead, specify only the columns you need—like id
, name
, or email
. This makes the query easier to read and significantly reduces data volume and CPU load. The improvement is especially noticeable when working with joins, aggregations, or LIMIT clauses in production queries.
Galaxy’s AI assistant detects SELECT *
usage and suggests targeted replacements based on schema and recent usage patterns. In most cases, switching to column-specific selects can yield 10–50% faster performance, particularly in user-facing applications and large table scans.
SELECT * FROM users WHERE active = TRUE;
SELECT id, name, email FROM users WHERE active = TRUE;
10–50% faster in large datasets