February 7, 2019 at 6:40 am
Grant Fritchey - Thursday, February 7, 2019 4:19 AMJeff Moden - Wednesday, February 6, 2019 11:06 PMOne of the things that I absolutely don't understand is why they're doing replaces on both the product name column and the variable for such things like the TM symbol. They really need to cleanup and homogenize their data.I'm sure this won't shock you, but 100% agreement. Rather than killing yourself trying to desperately find a way to tune a query that just will not tune, fix the code & structures that are the root of the problem. It's like fixing a leaky roof by fiddling with the windows or shoring up a shaky foundation by painting the walls. Focus on the root of the problem.
Heh... certainly no shock there, Grant. I just had to say it out loud. 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
February 12, 2019 at 9:31 am
The Product_Name column in the table contains lots of special characters like '®' ,'©',so i have to replace with TM,TS and CP characters.So now i am going to try with Computed columns concept for Product_Name and Custom Fields and i will use these computed columns in my procedure. is this method improve performance?Computed columns and Calculated columns are same?
February 13, 2019 at 12:41 pm
jkramprakash - Tuesday, February 12, 2019 9:31 AMThe Product_Name column in the table contains lots of special characters like '®' ,'©',so i have to replace with TM,TS and CP characters.So now i am going to try with Computed columns concept for Product_Name and Custom Fields and i will use these computed columns in my procedure. is this method improve performance?Computed columns and Calculated columns are same?
Are you highly confident that the actual character lengths in F_CUSTOM1, F_CUSTOM2, and F_CUSTOM3 are much less than 4000 characters?
If you are, I would also suggest using a LEFT or SUBSTRING function in your computed column definitions to limit the columns to the appropriate lengths. (I do notice that you have defined @PRODUCTNAME as NVARCHAR(200). So why not have the computed column definition as LEFT(REPLACE(F_CUSTOM1,'^',''), 200)?
February 13, 2019 at 1:01 pm
jkramprakash - Tuesday, February 12, 2019 9:31 AMThe Product_Name column in the table contains lots of special characters like '®' ,'©',so i have to replace with TM,TS and CP characters.So now i am going to try with Computed columns concept for Product_Name and Custom Fields and i will use these computed columns in my procedure. is this method improve performance?Computed columns and Calculated columns are same?
Why do you "have" to replace special chars in the column in the table? That will cause huge performance overhead. You'd be much better off changing the chars in the search column value. Even, worst case, if you have to do two searches for the value.
<key_columns> = 'SomeName®' OR <key_column> = 'Some Name|TM'
In fact, given those types of issues here, I'd put the actual names in a separate table. That would translate the product name to a corresponding int (or bigint if necessary) value, then use the int/bigint for the lookup to the main table.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
February 21, 2019 at 12:23 pm
F_SUBFORMAT is an index on its own. Why not make the last condition "AND EXISTS (SELECT 1 FROM AllSubformats ASF WHERE ASF.Val = TP.F_SUBFORMAT)" into an INNER JOIN in the main FROM table source? Depends on how many records that do not have a 'valid' F_SUBFORMAT in the AllSubformats table (or view), that might help filter out a whole bunch of records in the result set right off the bat.FROM T_PDF TP
INNER JOIN AllSubformats ASF ON ASF.Val = TP.F_SUBFORMAT
LEFT JOIN V_PROD_ALIAS_SYN SYN ON SYN.F_PRODUCT = TP.F_PRODUCT
Also, the code is doing the same REPLACE on both sides of the comparison between F_PRODUCT_NAME and @PRODUCTNAME; but it is not doing any REPLACE on F_CUSTOM1, 2, or 3. So why can't the REPLACE be removed and compare F_PRODUCT_NAME with @PRODUCTNAME as-is? UNLESS, F_PRODUCT_NAME contains both formats of the TM symbol and "|TM", TS symbol and "|TS", etc.
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply