1

I have some Sql tables with a primary key that's includes more column. I created a view on this tables and I added a computed column that is a concatenation of table's primary key, separated by a separator. (for example: ColumnA$ColumnB$ColumnC is concatenation of Column A, B e C that's table key). When I use this view I filter on computed column to work with primary key. In other case I have a query that put in join more view. Foreign key on the view is computed like primary key and the joins are on computed column.

The scope of this work is to simplified key to simplified integration with other software.

Could this execution scenario affect significatly performance?

Thanks in advance Luca

Luca Murzio
  • 37
  • 1
  • 5

1 Answers1

1

Better idea would be to keep these columns separately just as you have them natively in your tables, then you can create your index/PK based on all 3 columns not just a concentrated single one. For the performance I would probably suggest here to use indexed view here. Other way if we talk about 3 string columns you can use some hashing techniques as long as you can handle that extreme minimum hashing duplication exception on your application end.

Bartosz X
  • 2,620
  • 24
  • 36
  • Materialized view isn't possibile in my framework, I will evaluate hashing to understand if it is good for my problem. – Luca Murzio Nov 14 '18 at 07:46