mysql - Query performance: Query on multiple tables Vs. Composite query -


table has column srno , few other columns.

table b has columns srno , id.

i want srno b given id , fetch out record(s) srno table a.

for example, if id 7 can think of doing 2 ways:

select * table_a, b table_b table_a.srno=table_b.srno , table_b.id=7; 

and,

select * srno in (select srno b id=7); 

both doing same. when there huge number of records in both tables, performance wise better? or both have same performance? (let's assume here proper indexing etc has been taken care on these 2 tables. want performance comparison between these 2 queries)

your second query slower. type of dynamic in clause in mysql never approach.

my recommendation use first query, rewrite using ansi joins syntax , select minimal set of columns need, rather doing select *.

this starting point:

select table_a.*  table_a  inner join b table_b on table_a.srno=table_b.srno  table_b.id=7; 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -