Why You Should Design Your Database to Optimise for Statistics

In my SQL Masterclass, I frequently remind participants of the fact how important statistics are for a modern cost based optimiser. For instance, if you consider the fact that in an average E-Banking system's bookings table, you will probably have a transaction amount histogram like the following: In other words, most of your transactions are … Continue reading Why You Should Design Your Database to Optimise for Statistics

NOT IN vs. NOT EXISTS vs. LEFT JOIN / IS NULL: MySQL

When you're spoiled with Oracle's fabulous query transformation capabilities and its really well-done cost-based optimiser, then you might forget how difficult SQL query tuning used to be in the "old days" or with those less sophisticated databases. Here's a really nice explanation of the various means of implementing an ANTI-JOIN in MySQL: http://explainextended.com/2009/09/18/not-in-vs-not-exists-vs-left-join-is-null-mysql/