Reduce resource use query

1 with fewer resources occupancy way to write sql, such as memory, cpu, IO. Through the following means

Write sql 2 less resource-intensive way;

Sql 3 prepared using the procedure more efficient way cache;

 

 

1 to avoid resource-intensive query

Avoid data type conversion

Compare the type of data the column with the column definition if not the same type, will be converted to defined types, increased CPU consumption

Instead of using EXISTS COUNT (*) to verify the presence of Data

Because you want to scan all lines

Use UNION ALL instead of UNION 

To avoid the loss of data is merged

Using an index to polymerization or sort operation

Shoot well in advance of the order

Prudent use local variables in batch

Be careful of using the name of a stored procedure

Write sql 4 reduce network overhead way;

SET NOCOUNT ON <SQL queries> SET NOCOUNT OFF

The number of rows affected will not return

Write sql 5 ways to reduce query transactions consumption;

Use while the transaction will increase the consumption of the log file

 

Guess you like

Origin www.cnblogs.com/PerfectBeauty/p/11318152.html