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.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e48752-271f3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e48752-271f3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?