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