Category: SQL
Unreadable SQL
How to write Unreadable SQL… and why you shouldn’tWe’ve all seen it: a 200-line SQL query with no indentation, cryptic column aliases like a1, x, tmp, no comments, and nested subqueries that make your eyes bleed. It runs. It works. But six months later, nobody, not even the original author, can understand it. I’ve spent…
Read MoreTemporary Tables
Temporary Tables still there 5 years later.Why your junior dev’s temporary table is still there 5 years later We’ve all seen it: a table named tmp_orders_2020, test_customers_backup, or temp_report_john, created just for a quick test, but still sitting in production years later, full of outdated data, wasting space and confusing everyone. In my 35 years…
Read MoreDatabase Normalization
Database Normalization: Great Servant, Terrible Master Normalization is one of the most preached concepts in database design. Many SQL gurus treat it like a religion: chase the highest normal form (5NF or even 6NF) at all costs. But in the real world, especially in OLTP systems (online transaction processing) and even many analytics setups, blind…
Read MoreSQL is not a Programming Language
SQL is not a Programming Language. You’ve probably heard someone say “I know SQL” when asked about programming languages. Or maybe you’ve seen job ads listing SQL next to Python, Java, or C#. Technically, they’re wrong. SQL is not a programming language.It’s a query language, and that difference is its greatest strength. Let me explain…
Read MoreMonitoring PostgreSQL activity
Monitoring PostgreSQL activity with pg_stat_activity.PostgreSQL is incredibly powerful, but like any database, it needs occasional monitoring to stay healthy. One of the simplest and most useful tools for this is the built-in view pg_stat_activity. What Is pg_stat_activity?It is a system view that shows real-time information about every current connection to your PostgreSQL server. Run this…
Read MorePostgreSQL snapshots
What are snapshots in PostgreSQL, how do they work, and why you might need them. Snapshots are a key part of achieving Isolation in ACID. Let’s break it down quickly. ACID recap:Atomicity → All or nothing (transaction commits fully or rolls back).Consistency → Database moves from one valid state to another (constraints, triggers, etc.).Isolation →…
Read More