sql - Are these queries same? -
any pros , cons on following ways of fetching employees hr department? performance perspective?
--1 select * employee emp join department dep on emp.depid = dep.id , dep.name = 'hr'; --2 select * employee emp join (select * department dep dep.name='hr') d on emp.depid = d.id; --3 select * employee emp join department dep on emp.depid = dep.id dep.name = 'hr';
p.s. have same query plan , cost
--1 select * employee emp join department dep on emp.depid = dep.id , dep.name = 'hr';
for me best query, because match data employee department data department hr named. restrict data department table in join.
--2 select * employee emp join (select * department dep dep.name='hr') d on emp.depid = d.id;
this baddest query, because sub query costly rdbms. first rdbms execute sub query, , match employee table. using 3 full reading table.
--3 select * employee emp join department dep on emp.depid = dep.id dep.name = 'hr';
this option write, , if see execution plan converts on same 1.
Comments
Post a Comment