CAST Issue on join Creating index scan - poor performance

  • 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!

  • 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[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply