HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Does schema binding views affect performance?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
affectviewsperformancebindingdoesschema

Problem

Does schemabinding views affect performance in SQL Server or is just to prevent accidental changes?

Solution

With schemabinding can improve performance in some cases.

I couldn't recall all the details, but found an excellent blog post that goes through this in detail:


With user defined functions that may need to update data. You might
benefit from improved performance that would prevent an Eager Table
Spool.
SQL Server SCHEMABINDING

Edit: Paul White indicated that this doesn't actually impact view table spools just used for joins.

Schema binding definitely adds some additional maintenance when changing schema. This could be considered a good thing, since it prevents underlying schema changes without handling the binding. This doesn't bother me as I'm using Red Gate SQL Compare and it handles this, but if you are not using a tool to generate scripts this could be a factor to consider... (solved by getting a tool to generate the scripts!)

See also Improving query plans with the SCHEMABINDING option on T-SQL UDFs on the Microsoft SQL Programmability & API Development Team Blog.

Additionally, the comment by Kin on your original question brings up a great additional point regarding the potential to index the view once you have schema binding included. This can be considered an additional benefit that might help.

Context

StackExchange Database Administrators Q#138059, answer score: 8

Revisions (0)

No revisions yet.