Some good Optimizations

Source: Internet
Author: User
Code

Database Optimization

L 64-bit mssql2008:

Use fewer triggers/Cursor/Foreign key. Use multiple Storage Processes and views. A proper amount of index queries will increase the speed. Each table should have no more than three indexes.
Check the deadlock process and wait process at regular intervals, clear the process, and correct the source of the deadlock in time.
Complex statistical reports must be run with plans.
Count (0) Do not use count (*).
Do not use table fields when selecting*.*It is slow to query all fields.
If the field is an index column, you can use Union all to replace or to query it using the index line.
Paging query is required for a large record set.
Try not to use text/Ntext type. Use varchar (max)/Nvarchar (max ).
Try not to use temporary tables. Use the table type or embedded view.

Backend Optimization

L use dbdatareader instead of datatable/Dataset reads data.

LFor(IntI= 0; I<DT. Rows. Count; I++) It should be written as follows:

For(IntI= 0, Len=DT. Rows. Count; I<Len; I++) Or

Foreach(Datarow infoInDT. Rows ).

L use less tryCatchTo use try catch together with finally.

L use using more, for example:

Using(Dbdatareader Dr=Data. getdbdatareader (strsql )){While(Dr. Read ()){};}

L for large string operations, use stringbuilder to use less string, compare for string comparison, Concat for string addition, and stringbuilder append for large string addition.

L variables must be defined first and not in a loop. For example:

incorrect syntax: for ( int I = 1 ; I 10 ; I + ) { string S = I. tostring () ;}

correct syntax: string S = string . empty; for ( int I = 1 ; I 10 ; I + ) {S = I. tostring () ;}

Note: When adding strings, if there is an int type, convert it to the string type before addition to reduce unnecessary binning operations.

L if you are using an HTML control, disable it. <% @ Page enableviewstate = " False " Autoeventwireup = " False " Enablesessionstate = " False " , Web. config < Pages enableviewstate = " False " Enablesessionstate = " False "   />

L use foreach instead of

L use the stored procedure to operate databases/View.

L use the cache to cache data. This is the key. Net: httpcontext. Current. Cache/Httpruntime. cache, shared cache with velocity/Memcached

L available<%@ Outputcache duration="60"Cache page, you can use response. bufferoutput= True;/ <%@ Page Buffer="True"Output buffer.

L The site can be generated to generate static surface pages, with many benefits.

L URL can be rewritten to pseudo-static to provide RSS/Baidu-Sitemap/Google-The sitemap service facilitates search engine indexing.

L use. ashx for Ajax call pagesProgramThe speed is faster than that of the. aspx file. Do not use get for Ajax requests that require post.

L release the dll version when releasing the site. Do not use the debug version.

L IIS must use the integration mode instead of the Classic mode.

L web. config and<Customerrors Mode="On" />Disable the error message.

L web. config and<Compilation debug="False" />Disable debugging mode.

L replace response. Redirect with server. Transfer

L use more generic set operations and use less arraylist.

Frontend Optimization

L it is best not to use the net control, HTML control, and CSS on the page+Div layout.

L use JSON+Ajax for data interaction.

L learn to use jquery to improve development speed.

L use as few as possible<Use the background style to control the background image. The advantage of doing so is to facilitate the expansion of multiple skins.

L combine multiple CSS Background images into one image to ensure that the size of the merged image cannot exceed 50 kb. JavaScript files can be merged into a JS file and then compressed using closure_packer_yui_compiler. This reduces the number of client connections.

L JSCodeDo not place segments on HTML pages. They should be placed in an independent JS file. The advantage is that JS files can be stored on CDN./Cache.

L put the CSS file<Head> </Head>, Put the JS file or code in</Body>Previously, let the page first display in the execution of Js.

L website images can be uploaded/CSS/JS/Materials/Resources are placed on independent sites for CDN acceleration. Second-level domain names have cookies. It is best to use first-level domain names.

L a mark and IMG mark need to be added with title/ALT,<Head>The title must be added to the tag./Keywords/Description/RSS/Sitemap is optimized to facilitate search engine indexing.

L you can enable gzip compression on the page.

L install the FF plug-in "yslow"/Page speed ".

 

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.