SQL Server developers and SQL Server DBAs meet somewhere in the middle of the development life cycle. That’s the theory. In reality , with time and cost pressures , the DBA sometimes can be the last to know code is about to go live. There is a responsibility for the Developer to develop code with some understanding of the SQL Database Engine.
The way in which Developers approach coding has a big impact on the success of the project. Scalable code should be a central principle in coding. The code may work efficiently with a controlled set of data – but how does it scale with 10x the amount of users, or how does it deal with adding a new column a after the go-live date. This is where a good DBA advises and works with Developers to apply tactics for performant SQL Server.
SQL Tuning Advisor
The SQL Tuning Advisor promises much but can also lead to problems. No in-depth expertise is required, therefore tempting for non DBAs to run a sample workload. The Advisor typically recommends indexes and statistics. Do not just add them without considering the consequences , for example, a) Adding new indexes has an extra storage space requirement b) Extra maintenance is required . How will this impact the maintenance window?
SQL Server TempDB – Does not retain permanent data
Tempdb is cleared out everytime there is a SQL Server restart. Think of Tempdb as a temporary data store, for Application data and Internal operations. There is only one TempDB per SQL Server Instance – it is possible a query hitting one database supporting one application can adversely impact another application using another database on the same Instance.
TempDB performance and strategy checklist
Temporary Tables versus Table Variables
SQL Query Optimizer is cost based
The SQL Query Optimizer works on a cost-based model . There doesn’t appear to be any obvious measure of acceptance , apart from a comparison to other potential Execution Plans. From a developers perspective , the key to maximising the process is to write efficient code. This means not only focusing on Set- Based principles , but also working with a DBA to study the Execution Plan . Ensure Statistics are kept up to date – as Statistics remain a fundamental part of Optimization.
Query Hints are a powerful tool, but be wary of using them. Generally , if the SQL Server is maintained properly , it will choose a suitable Execution Plan. Generally , I don’t recommend them as there is always potential to create new problems.
SQL Server Query Optimizer and Statistics
Transact-SQL and the xQuery language
Transact-SQL (T-SQL) is fundamental in using SQL Server. All types of applications use SQL server , but they all use T-SQL to communicate.
Querying xml data requires using the XQuery language. XQuery is used for Structured and semi structured xml data.
Avoid using XML for storing and retrieving data. Based on experience the XML data type is very slow.
Love your DBA
A good DBA will work hard to monitor and maintain the Database Server. In the background , they will usually be fixing many small bugs and issues that can topple the server . Database Servers are part of a large IT ecosystem – when you consider SAN storage, backups, high availability, monitoring, networks etc , many things can go wrong.
As the developer cultivate a good relationship with the DBA , for example , set up a review process of new code going into Production. Try not to rush code into Production because a manager is shouting . It’s in everyones interest to maintained optimized code. Contact me for any questions
Related Posts
SQL Server – DBA: Daily Routine
SQL Index Usage
SQL Server Performance Killers
DBA supertech . Specialise or generalise?
Stored Procedures versus ad-hoc paramaterized queries.Which is faster?