Enlightensoft's Blog

Helping in your each step

  • Categories

  • Authors

Archive for the ‘Performance’ Category

Database

Posted by Pankil Patel on March 31, 2010

During fetching record for referential integrity.

Instead of using “IN”  query use inner join / Cartesian product or Cross join, it will be very much faster than “IN” query.

Example:

IN Query:

select * from employee e where e.userId in (select u.userId from user u where u.status = “A”)

Inner Join Query:

select * from employee e inner join User u on u.userId = e.userId and u.status = “A”

Cartesian product or Cross join:

select * from employee e, User u where e.userId = u.userId and u.status = “A”

Advertisements

Posted in Performance | Leave a Comment »