Millions of data query optimization in SQL SERVER database

Source: Internet
Author: User

1. When you need to query all the data in the table

Compare the following three types of query statements:

Suppose the data table is BasicMsg20170401, there are 17 columns, and the number of data bars is 2.84 million

(1) SELECT * from BasicMsg20170401

Takes more than 44 seconds

(2) SELECT column 1, column 2 ... From BasicMsg20170401

Takes 28-30 seconds up and down

(3) SELECT column 1, column 2 ... From BasicMsg20170401 with (index (SELAA_INDEX))

After forcing a nonclustered index, it takes time to 23~28 up and down

Summary: Add mandatory index, when the amount of data is less than the number of optimizations, the amount of data is large, there will be a bit of optimization. A large number of data queries, as far as possible without select *.

When the database is slow to find queries, you need to check the database initial value size and the way the data grows, or place the database filegroup in a different disk space.

2, generally do not need to query the full table data, as far as possible after the query statement to add filter statements, filter keys as far as the index column

Query 2 million data 30 seconds, if you add an index on "column 1", you can use the following query statement

SELECT column 1, column 2 ... From BasicMsg20170401 with (index (SELAA_INDEX)) where column 1<=35500000

Millions of data query optimization in SQL SERVER database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.