Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query performance with INNER JOIN

Author  Topic 

karlman
Starting Member

11 Posts

Posted - 2010-04-04 : 13:33:04
I have a question about QUERY performance. Does an INNER JOIN that is not referenced in the WHERE clause only a minor affect on speed?

I have a table that will eventually have millions of records. I need to be able to search this table quickly by a primary key. I also want data from another related table. If I add that to an INNER JOIN does the INNER JOIN portion only get executed for the records that are actually found in the primary table?

SELECT * FROM Transaction t
INNER JOIN Header h ON h.HeaderID = t.HeaderID
WHERE t.MatchValue LIKE '%[searchvalue]%'

Thank you

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-04 : 13:53:03
it will only work on exact matches. b/w what all indexes you've on tables?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-04 : 13:59:32
It's not the JOIN that will be the problem, it's the LIKE with the wildcard at the beginning that would hurt performance.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -