Skip to main content

SQL Server Tuning for Faster Queries

Your SQL Server Compact is capable of lightening-fast performance and stunningly efficient service even while handling huge work loads. But without regular SQL sever performance tuning, you can’t expect it to “win the race” any more than a race car could without regular tune ups.

You will have an opportunity to read in-depth information about SQL Server performance if you visit this Stackify page. But for a basic overview of the most important principles for your SQL tune-ups, keep reading right here.

race car maintenance

Image Source

About SQL Server Tuning

It would be nice to think that you could handle SQL performance tuning in a single, end-all strike, but what it’s really going to take is a targeted, involved, and “never-ending” campaign. Slow SQL performance may be caused by only one or two slow but frequently used queries that are eating up all your active memory. It’s a “search and destroy mission.”
Realize that your query processor has to compile, perfect, and generate an execute plan before it can even start an actual performance. Also realize that there may be numerous ways to do any given query, but only one of them is the most efficient. And what works in one scenario won’t work somewhere else. And what worked best last year may be only second-best (at best) this year.

Buckets and Metrics

As you regularly test and retest, record the result and search for of the fastest, least expensive, lowest memory consumption solution, you need to learn to “think in buckets.”
“Buckets” is tech-talk for units of similar data-types. It’s the way you organize things when you are looking for a problem. You ask, “Is the issue in resources, in query structure, in indexing, or somewhere else?” It’s the equivalent to a mechanic asking, “Is the problem with the engine, transmission, electrical system, or the body?”

Next, keep in mind you will be using numerous data metrics as you fine tune your query searches for optimal performance. Your boss will likely be happy with even a slight uptick, just like a track runner shaving seconds off his mile.

The key is to not only understand and have access to great metrics, but to know how to correlate them correctly. You have to be able to deduce where the problem is by comparing various metrics. You look at wait states, CPU, throughput, memory pressure, bandwidth, usage, and more, and “triangulate” to find the issue. Use the Database Performance Analyzer dashboard to make this process much easier!

Track Results Over Time

Again, this is a long-term undertaking, a never-ending war. To win, you need to keep collecting data at regular intervals (we’re talking about days, weeks, months); and then, compare this against last year’s or the last few year’s stats. That gives you perspective on how well you are doing and if you are improving/declining.

Of course, you’ll also want to get information on the industry average and pay attention to any goals your superiors may have set for you (or you may have set for yourself).

Do Regular Maintenance

Maintenance of your database is also key. As you pay attention to maintenance tasks, you both prevent SQL issues and gather the data that can help you solve certain SQL problems should they arise.

Specifically, hour-by-hour transaction log backups plus daily and weekly backups; daily index maintenance (not necessarily rebuilding indexes every day though), statistic updating, and corruption checks should all be a part of your maintenance routine.

The post SQL Server Tuning for Faster Queries appeared first on The Crazy Programmer.



from The Crazy Programmer https://www.thecrazyprogrammer.com/2017/10/sql-server-tuning-faster-queries.html

Comments

Popular posts from this blog

Rail Fence Cipher Program in C and C++[Encryption & Decryption]

Here you will get rail fence cipher program in C and C++ for encryption and decryption. It is a kind of transposition cipher which is also known as zigzag cipher. Below is an example. Here Key = 3. For encryption we write the message diagonally in zigzag form in a matrix having total rows = key and total columns = message length. Then read the matrix row wise horizontally to get encrypted message. Rail Fence Cipher Program in C #include<stdio.h> #include<string.h> void encryptMsg(char msg[], int key){ int msgLen = strlen(msg), i, j, k = -1, row = 0, col = 0; char railMatrix[key][msgLen]; for(i = 0; i < key; ++i) for(j = 0; j < msgLen; ++j) railMatrix[i][j] = '\n'; for(i = 0; i < msgLen; ++i){ railMatrix[row][col++] = msg[i]; if(row == 0 || row == key-1) k= k * (-1); row = row + k; } printf("\nEncrypted Message: "); for(i = 0; i < key; ++i) f...

Data Encryption Standard (DES) Algorithm

Data Encryption Standard is a symmetric-key algorithm for the encrypting the data. It comes under block cipher algorithm which follows Feistel structure. Here is the block diagram of Data Encryption Standard. Fig1: DES Algorithm Block Diagram [Image Source: Cryptography and Network Security Principles and Practices 4 th Ed by William Stallings] Explanation for above diagram: Each character of plain text converted into binary format. Every time we take 64 bits from that and give as input to DES algorithm, then it processed through 16 rounds and then converted to cipher text. Initial Permutation: 64 bit plain text goes under initial permutation and then given to round 1. Since initial permutation step receiving 64 bits, it contains an 1×64 matrix which contains numbers from 1 to 64 but in shuffled order. After that, we arrange our original 64 bit text in the order mentioned in that matrix. [You can see the matrix in below code] After initial permutation, 64 bit text passed throug...

Experimental: Reducing the size of .NET Core applications with Mono's Linker

The .NET team has built a linker to reduce the size of .NET Core applications. It is built on top of the excellent and battle-tested mono linker . The Xamarin tools also use this linker so it makes sense to try it out and perhaps use it everywhere! "In trivial cases, the linker can reduce the size of applications by 50%. The size wins may be more favorable or more moderate for larger applications. The linker removes code in your application and dependent libraries that are not reached by any code paths. It is effectively an application-specific dead code analysis ." - Using the .NET IL Linker I recently updated a 15 year old .NET 1.1 application to cross-platform .NET Core 2.0 so I thought I'd try this experimental linker on it and see the results. The linker is a tool one can use to only ship the minimal possible IL code and metadata that a set of programs might require to run as opposed to the full libraries. It is used by the various Xamarin products to extract...