Jonathon Hill / rss feed
I’m a big believer in readability, and I love to write code that is easy to understand. Check out my newly-posted MySQL Style Guide which covers: Simple queries Complex queries Subqueries UNIONS Advanced queries Useful tips: Use table aliases sparingly and only when absolutely necessary (a few extra keystrokes now will save you hours of gazing at cryptic queries later) CAPITALIZE keywords religiously Whitespace [...]
Sometimes MySQL doesn’t use the index on a column when performing a query. Indexes are NOT used if MySQL can calculate that it will probably be faster to scan the whole table. For example if key_part1 is evenly distributed between 1 and 100, it’s not good to use an index in the following query: SELECT * FROM [...]