Search code examples
sql-server-2012cardinality

Should I try stop Implicit Conversion?


I have a table that is in a database I am not allowed to edit as it belongs to a third party. They have a field with datatype Char(2) this fields holds the following values:

01
02
03
04

I also have several other tables both physical and temp that have this same field and values. I am working on making a massive table that combines data between these tables. However when I run the code with just selecting that field not doing anything to it the execution plan does an implicit conversion to int.

I do not care that the field is int as that makes more sense to me anyways but the execution plan also states that the conversion

"may affect cardinality estimate"

I am having issues with this code running slow and was thinking this might be the problem.

Should I try to find a way to stop the conversion or is it likely not causing my slow down?

Edit: Extra info this column is used in joins

Let me know if you need more info.

Using SQL 2012


Solution

  • You could create a new table with yours INT ID and the Char(2) column (like a domain table). You could turn this INT column like PK and FK in your others tables. So you will compare INT x INT in yours tables and Char(2) x Char(2) with this new table and the third party table. This could be work for you. (sorry about my english)