MS SQL Server Optimizer and various table and field aliases

We have many queries for which we add a random alias at the end of the field and table name (due to a custom ORM implementation, which can be difficult to change). The queries are similar to the following (although much more complex, more often):

SELECT fooA.field1 as field1B, 
       fooA.field2 as field1C 
FROM foo as fooA

The suffixes A, B, and C are randomly generated (and longer than one character). Will this worsen the execution of our queries (i.e., the Optimizer will not be able to recognize duplicate queries due to a random part)? We mainly use SQL Server 2005.

+3
source share
3 answers

, , .

+3

, ObjectId - , . , .

Quassnoi . , , .

+1

ad-hoc-, . SQL ' , , ( case white-space)

If you have many queries that differ only in the table aliases, then you will have very poor plan reuse, lots of compilation and very large plan cache.

It stores procedures that match cached plans using objectid

+1
source

Source: https://habr.com/ru/post/1718467/


All Articles