Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

CAST Issue on join Creating index scan - poor performance Expand / Collapse
Author
Message
Posted Wednesday, November 13, 2013 2:12 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, November 18, 2013 9:18 PM
Points: 51, Visits: 215
I am having an issue with a query causing Index scan and poor performance:

Here is an example of what I am doing:

SELECT orderid
FROM table1 o inner join table2 t
On CAST(o.invoiceid as char(10) = t.invoicedid
Where o.invoiceid = '123456'

How can I make the join searchable and or how to eliminate table scan?

Thank you so much!
Post #1514059
Posted Wednesday, November 13, 2013 2:57 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:54 AM
Points: 6,957, Visits: 12,717
What's the reason for the CAST conversion?
It seems like o.invoiceid is already a character data type. What exact data type are the two columns referenced in the join predicate (o.invoiceid and t.invoicedid)? What does the actual execution plan look like?




Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1514076
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse