SQL Optimization Techniques

Avoid SELECT * for Faster Queries

General Tuning
Performance

Querying only the columns you need can significantly reduce processing time and resource use.

Ourv0.1-alphais coming in May 2025.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Performance Insights

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.

Before Optimization

SELECT * FROM users WHERE active = TRUE;

After Optimization

SELECT id, name, email FROM users WHERE active = TRUE;

Estimated Improvement

10–50% faster in large datasets

Check out other SQL optimizations!

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
Comulate
Truvideo Logo