SQL is derided by many and for good reason. It’s key to scalability yet terribly difficult to write good code.
You can write tighter queries in MySQL easily by following 3 simple tricks –
SUBQUERIES, UNION, and PAGING.
In this article, we will explain all these patterns to write MySQL codes more efficiently.
3 Best and Simple Ways for Tighter MySQL Code
Here are a few quick tips to write tighter queries in MySQL:
1. Get Rid of Those Subqueries!
Subqueries are a standard part of SQL, unfortunately, MySQL doesn’t handle them very well. Luckily there’s a sweet rewrite that can put you in the fast lane. Here’s how to speed up a MySQL subquery by rewriting as a join.
Note that another compelling reason to upgrade to MySQL 5.6 is that this tweak has been rolled into the …
[Read more]