Close the project recently. After finishing the project documents, you can see the previous labels for performance optimization. Express your views for the purpose of joint discussion with everyone. You are welcome to discuss this. please correct me if you have any mistakes. (This article does not involve
Cahe Deep mechanism application and research, just some superficial applications and suggestions)
Optimization of Data Processing
I,SqldatareadAndDatasetSelect
SqldatareadAdvantage: Reading data is very fast. We recommend that you useSqldatareader, Its performance is betterDatsetA lot better. Disadvantage: it is not available until the data is read.CloseConnection to the database
(Sqldatareader Reading data is fast forward.SqldatareaderClass providesSQL ServerDatabase Retrieval Method. It usesSQL ServerThe Local Network Data Transmission Format for reading data directly from the database connection.DatareaderExplicitClose. Data connections can be released in a timely manner.)
DatasetRead the data and cache it in the memory. Disadvantage: High memory usage. If a large amount of processing is required for the returned dataDatasetIt can reduce database connection operations. Advantage: Only one connection is required.CloseDatabase Connection
*Generally,Read large amounts of data,Do not process the returned data in large quantitiesSqldatareader.Massive processing of returned dataDatsetSuitable.PairSqldatareaderAndDatasetDepends onProgramFunction implementation.
II,Executenonquery and executescalar
No result set is required for data update. We recommend that you useExecutenonquery. Because no result set is returned, network data transmission can be saved. It returns only the number of affected rows. If you only need to update data, executenonquery has a low performance cost.
Executescalar only returns the first column of the First row in the result set. Use the executescalar method to retrieve a single value (for example, an ID number) from the database ). This operation requiresCodeRelatively small.
* You only need to update the data using executenonquery. Use executescalar to query a single value.
Data Binding Selection
III,Data BindingDatabinder
General Binding method<% # Databinder. eval (container. dataitem ,"Field name") %>
UseDatabinder. EvalBinding does not concern about data sources(DatareadOrDataset). Don't worry about Data TypesEvalConverts the data object to a string. It does a lot of work on the underlying binding and uses the reflection performance. This is because it is easy to use, but affects data performance.
Let's see<% # Databinder. eval (container. dataitem ,"Field name") %>. WhenDatasetWhen binding,DataitemActuallyDatarowview(If a data reader (Dataread) It isIdatarecord.) Therefore, directly convertDatarowviewIt will greatly improve the performance..
<% # Ctype (container. dataitem, datarowview). Row ("Field name") %>
*Data Binding is recommended.<% # Ctype (container. dataitem, datarowview). Row ("Field name") %>. When the data volume is large, the speed can be increased by several hundred times. Note2Aspect:1.You need to add<% @ Import namespace = "system. Data" %>. 2.Note the case sensitivity of the field name (Special note). If it is inconsistent with the query, in some cases<% # Databinder. eval (container. dataitem ,"Field name") %>Slow down. If you want to further increase the speed, you can use<% # Ctype (container. dataitem, datarowview). Row (0) %>. But its readability is not high.
The simplest way to view the status of each Execution Process on the page:TraceThe property isTrueYou can view the details.