Data Types & Constraints: Performance
Module: Foundational Concepts
Use smallest data type that fits your data. SMALLINT (2 bytes) vs INTEGER (4 bytes) saves 50% storage. Index columns with constraints for faster queries.
Smaller data types = less storage and faster queries
SMALLINT (2 bytes) vs INTEGER (4 bytes) saves 50%
VARCHAR for variable text, CHAR only for fixed codes
Index columns used in WHERE and JOIN clauses
Perf Impact: Functions/conversions in WHERE: No index use. Move to computed columns
Using FLOAT for money (rounding errors)
Forgetting NOT NULL on required fields
Using VARCHAR for dates (no validation)
Missing CHECK constraints for business rules
Using INTEGER when SMALLINT would suffice