|
|
|
|
|
by Foobar8568
2407 days ago
|
|
I would add to the common mistakes (should be generic, but I have more xp with sql server) : not indexing, most often, tables are not or poorly indexed. Implicit conversion can generate a lot of io/leads to poor perf or just not using indexes. Sql function:sorry but they are most often crap and useless, better to in-line or use TVF, and no its not code logic duplication. Read uncommitted unless you enjoy not reading rows, multiple times or half of a value (page split and/or LOB values) |
|
Functions have helped me tremendously in SQL server, but you do have to know the issues, which can be taken advantage of to some degree.
Code reuse is the obvious use case, but due to lack of inlining up to SQL Server 2019 meant you could reduce performance compared to hand inlined case statement or whatever. Hopefully now that functions can be inlined in 2019 this will be a non issue going forward
They are an optimization barrier which can be a good thing. I have used to this my advantage to stabilize tricky queries that where using views for code reuse. The performance becomes consistent and predictable rather than going pathological on some databases even though it may be slightly slower on others.