everytime I make querys to my 40k database I use LEFT JOIN instead of adding the table to the FROM and then use AND with a condition, it's the way I learned to do it. I mean.... and this is not a real query...
I USUALLY DO THIS:
SELECT * FROM (`table_A`)
LEFT JOIN `table_B` ON `product`.`table_A` = `product`.`table_B`
WHERE product.table_A > 0
INSTEAD OF
SELECT * FROM (`table_A`, `table_B`)
WHERE product.table_A > 0
AND `product`.`table_A` = `product`.`table_B`
The fact is that every time I use LEFT JOIN
in whatever query I make to the database, independently of the tables or the kind of querys, a time of 0,0012 seconds becomes 0,5 seconds or even 2-3 seconds. So, the second query is always faster than the first query using LEFT JOIN
.
What's going on? Could have something to do with the memory assigned to the join_buffer_size or another parameter in MySQL?
I'm using MySQL 5.5. version. BTW, If I use 5.6 all the querys takes at least double time.