sql server - duplicate data or better performance? -


we need display our product name in different languages, of them have name in different language english. when query products language, want show default name in english if language name missing.

to better query performance, have fill default english name language dependent product name table (languageid + productid primary key) when name language missing. made lots of duplicate name in language dependent table , it's bit difficult update table when default english name changed.

currently, have 300,000 products 30 languages , more 8,000,000 rows in table, @ least more 90% data duplicate , fill default english name. if use left join , isnull check in query, query performance slower.

who can recommend me better database design can avoid fill duplicate data , have better query performance?

the current tables schema below

table1 (about 300,000 rows) productid   | country        | currency  | others fields ------------|----------------|-----------|--------------- product   |             | usd       | ... product b   | gb             | gbp       | ...  table2 (about 9,000,000 rows) languageid  | productid      | product name ------------|----------------|-------------------------- english     | product      | product name english     | product b      | product b name german      | product      | produkt name german      | product b      | product b name (it's filled english name) 

i have tried below query avoid duplicate data, performance bit worst.

select     a.productid,     a.country,     isnull(b1.productname, b2.productname) productname     table1 (nolock)     left join table2 b1 (nolock) on a.productid = b1.productid     left join table2 b2 (nolock) on a.productid = b2.productid , b2.languageid = 'english'     b1.languageid = 'german' order     isnull(b1.productname, b2.productname) 

have tested left join , isnull? or guess? given shifting lot of data around, i'd optional language row far quicker unless have bad indexing

select    ...,    isnull(l.languageproductname, p.productname)    product p    left join    langaugestuff l on p.productid = l.productid , l.languageid = @mylanguage 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -