Which mysql statement performs better

select * from a where aa=1 and bb=2;

select * from a where in (select id from a where aa=1 and bb=2);

Mar.18,2021

the second feeling is superfluous. Performance mainly depends on whether there is an index on aa and bb


// 
select * from a where aa=1 and bb=2;

but why do you write the second operation like that? There is no doubt about this. If you think about it, the second one will run on the basis of the first one. Who do you think is fast? There are certain prerequisites for reducing fields and improving performance efficiency based on primary key queries, not that performance can be optimized by using primary key queries as much as possible.

Menu