A detailed Guide on sql query Optimization This article was published as a part of the


Download 243.81 Kb.
Pdf ko'rish
bet3/7
Sana03.02.2023
Hajmi243.81 Kb.
#1152366
1   2   3   4   5   6   7
Bog'liq
a-detailed-guide-on-sql-query-optimization

2. Reduced CPU execution time: The CPU execution time of a query must be reduced so that faster results
can be obtained.
3. Improved Throughput: The number of resources to be accessed to fetch all necessary data should be
minimized. The number of rows to be fetched in a particular query should be in the most efficient manner


such that the least number of resources are used.
Database for the tutorial
We will be using the AdventureWorks database in this tutorial for showing various commands and their
optimized solutions. You can download the database from 
here
.
AdventureWorks database is a sample database provided by Microsoft SQL Server. This is a standard
database used for showing day-to-day transaction processing for a business. Scenarios include sales,
customer management, product management, and human resources.
For more information on the tables, relationships of the database, you can visit this 
link
.
Metrics for analyzing query performance for SQL Query Optimization
There are several metrics for calculating the cost of the query in terms of space, time, CPU utilization, and
other resources:
1. Execution TimeThe most important metrics to analyze the query performance is the execution time of
the query. Execution time/Query duration is defined as the time taken by the query to return the rows from
the database. We can find the query duration using the following commands:
SET STATISTICS TIME ON SELECT * FROM SalesLT.Customer;
By using STATISTICS TIME ON, we can see the parse time, compile-time, execution time, and completion
time of the query.
Parse and Compile Time:  The time taken to parse and compile the query to check the syntax of the query
is termed Parse and Compile time.
Execution Time: The CPU time used by the query to fetch the data is termed Execution time.

Download 243.81 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling