Agenda Database Development – Best Practices Why Performance Matters ? Day to Day Real-Time Examples Demos Questions?
Why Performance Matters? Poor Performance Frustrated Clients Annoyed Support Team Finally it comes to you
Database Development – Best Practices Reduce the Number of Calls Original Query
Database Development – Best Practices Reduce the Number of Calls Performance Improvement
Database Development – Best Practices Try to Avoid CAST/ CONVERT Original Query
Database Development – Best Practices Try to Avoid CAST/ CONVERT Performance Improvement
Database Development – Best Practices Use Dictionary Tables Original Query
Database Development – Best Practices Use Dictionary Tables Performance Improvement
Database Development – Best Practices Avoid using Sub -Queries or Nested Queries Original Query
Performance Improvement Database Development – Best Practices Avoid using Sub -Queries or Nested Queries Performance Improvement
Database Development – Best Practices Effective Utilization of CTE Original Query
Database Development – Best Practices Effective Utilization of CTE Performance Improvement
Database Development – Best Practices Remove Unnecessary/Unused Variables Original Query
Performance Improvement Database Development – Best Practices Remove Unnecessary/Unused Variables Performance Improvement
Database Development – Best Practices Better Readability Original Query Performance Improvement
Database Development – Best Practices Use Stored Procedures Maintainability Encapsulation Security Performance Reduce Server/Client Network Traffic Code Reusability Error Handling
Writing Comments in a Stored Procedure Database Development – Best Practices Writing Comments in a Stored Procedure One very helpful thing to do with your stored procedures is to add comments to your code. This helps you to know what was done and why (for future reference) Also helps other DBAs or developers that may need to make modifications to the code.
Database Development – Best Practices Avoid Using Cursors Resources consumed by Cursors - occupies more resources (memory, IO, CPU) and temporary storage. Performance Issues - Each time when a row is fetched from the cursor it may result in a network round trip. This uses much more network bandwidth. Repeated network round trips can degrade the speed of the operation using the cursor. How can you avoid Cursors? Using WHILE LOOPS Using temp tables Using User defined functions
ALWAYS CONSIDER PERFORMANCE Database Development – Best Practices Just because your SQL data set has few records currently it doesn’t mean that the data set won’t grow significantly after you move it to production. One common mistake is to run a poorly performing query in development when the system has no users querying and very few records. The query runs fast, because there’s no load on the database server. Then, when the query is promoted to production and run in a busy environment, the query performs poorly and undermines site performance. Always consider performance even if the query seems like it won’t need many resources from the database server. ALWAYS CONSIDER PERFORMANCE Even if the Query seems Simple