Reputation: 111
is it possible to optimize this sql query in order to have better execution time in case of big sized tables
SELECT X.id,X.id2
FROM Table X, Table Y, Table Z, Table W
WHERE Y.id = 1
AND Y.dt = Z.dty
AND Z.el = 2
AND Z.id = W.idz
AND W.idx = X.id
Upvotes: 0
Views: 94
Reputation: 50163
Use proper standard explicit JOIN Syntax instead of commas:
SELECT X.id, X.id2
FROM Table X INNER JOIN
Table W
ON W.idx = X.id INNER JOIN
Table Z
ON Z.id = W.idz INNER JOIN
Table Y
ON Y.dt = Z.dty
WHERE Y.id = 1 AND Z.el = 2;
Just make sure you will have indexes on X(ID), W(idx), Z(id,dty,el), Y(dt,id)
Upvotes: 1