NavigationUser login |
MySQLWhat a difference a space makes
mysql> select count(*) from transactionHeaders;
Additional Criteria in a JOIN ClauseAdditional information in an ON Clause can be confusing. Consider the difference between
and
Based on http://www.sqlteam.com/article/additional-criteria-in-the-join-clause The first case does what you would expect - printing out books and sales data for store 123.
Lesson learntRunning the following query: SELECT orderId FROM orders where orderRef=737357947879; Was taking 2 seconds, despite the key on orders.orderRef It turned out that orderRef was a varchar (This was not my schema I hasten to point out - storing integers in varchars is definitely a bad idea!) SELECT orderId FROM orders where orderRef='737357947879'; was almost instantaneous MySQL was doing a full table scan casting orderRef to an integer at each step then matching with the integer I was passing in.
|
Recent blog posts |