Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2016 December SQL Server: The Importance of Statistics and Why It is important

SQL Server: The Importance of Statistics and Why It is important

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

Statistics for query optimization are objects that contain statistical information about the distribution of values in one or more columns of a table or indexed view.

The query optimizer of Microsoft SQL Server is a cost-based optimizer.
One of the most important of is the information about the number of rows that are expected to be returned when the query is executed. This information is gleaned from what is called Statistics.

If statistics are not accurate enough, the query optimizer of Microsoft SQL Server may choose an inappropriate execution plan because of overestimates the number of records.

When AUTO_CREATE_STATISTICS is on, query optimizer creates statistics for single columns and also query optimizer creates statistics for indexes on tables or views when the index is created.

If an error or other event prevents the query optimizer from creating statistics, the query optimizer creates the query plan without using statistics. The query optimizer marks the statistics as missing and attempts to regenerate the statistics the next time the query is executed.

Statistics updates can be either synchronous (the default) or asynchronous:

With synchronous statistics updates, queries always compile and execute with up-to-date statistics.
When statistics are out-of-date, the query optimizer waits for updated statistics before compiling and executing the query.

With asynchronous statistics updates, queries compile with existing statistics even if the existing statistics are out-of-date.

Your query response times might be more predictable with asynchronous statistics updates than with synchronous statistics updates because the query optimizer can execute incoming queries without waiting for up-to-date statistics.

The query optimizer determines when statistics might be out-of-date and then updates them when they are needed for a query plan.
In some cases you can improve the query plan by updating Statistics manually using sp_updatestats.
You can also set AUTO_UPDATE_STATISTICS is on.

Dec 15, 2016Anvesh Patel
SQL Server: Have a large Database, use Striped Database Backup & RestoreSQL Server: Enable Auto Create and Auto Update Statistics
Comments: 1
  1. mahesh
    July 26, 2017 at 7:42 am

    Nice theory anvesh

Anvesh Patel
Anvesh Patel

Database Engineer

December 15, 2016 SQL ServerAnvesh Patel, database, database research and development, dbrnd, SQL Query, SQL Server, SQL Server Administrator, SQL Server Monitoring, SQL Server Performance Tunning, SQL Server Tips and Tricks, Statistics, TSQL
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....