What is Selective Projection?
SELECT Comparison
| SELECT * | SELECT columns |
|---|---|
| More memory | Less memory |
| Slower network | Faster network |
| Can break code | Stable code |
3 rows
Only SELECT the columns you need. Avoid SELECT *.
Example
SELECT Comparison
| SELECT * | SELECT columns |
|---|---|
| More memory | Less memory |
| Slower network | Faster network |
| Can break code | Stable code |
3 rows
Bad:
SELECT * FROM products; -- Gets 20 columnsGood:
SELECT name, price FROM products; -- Gets only 2Why It Matters
SELECT Comparison
| SELECT * | SELECT columns |
|---|---|
| More memory | Less memory |
| Slower network | Faster network |
| Can break code | Stable code |
3 rows
Summary
SELECT Comparison
| SELECT * | SELECT columns |
|---|---|
| More memory | Less memory |
| Slower network | Faster network |
| Can break code | Stable code |
3 rows
- Always list columns you need
- Avoid SELECT * in production
- Less data = faster queries