Some suggestions for SQL script writing

Source: Internet
Author: User

1, index is critical, create a reasonable index, improve query speed;          DBCC freeporccache      dbcc dropcleanbuffers  & nbsp;                                                                                             SET statinstic IO   on         SET statinstic IO off      1> query, where The statement also involves whether the query uses an index lookup or an index scan;     2> uses the SQL real-time query tool to analyze query performance, using an index performance higher than scanning the disk;     3>where Try not to use a calculated expression such as year () in the statement, resulting in a query, use non-index lookup;     4> try not to use the word select * from tables, a resource-intensive, two, may lead to queryNo index;     5> predicate data and type non-conformance can also cause the query to not use an index lookup;                                                                                                                                       2, SQL use a few suggestions:
1> use stored procedures as much as possible, one to reduce traffic two to prevent some SQL injection, 2>sql transaction execution will not be due to a statement error and rollback, so when executing, need to use Try...catch configuration; 3> predicates and types are as consistent as possible; reference documentation: S QL Server to programmers (easy to ignore errors)How I handle 430 million records per day in SQL Server                         ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                                                            ,         &N Bsp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                

Some suggestions for SQL script writing

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.