【正文】
testTable END Code 1. Query that returns all data from a database When there are a lot of records to display in a web page, it is a mon practice to show only a limited number of records (a page of records) and to allow the user to navigate through the pages of records . to use ―data paging‖. Databound controls such as GridView can use the automatically provided mechanisms for sorting and paging in databound and datasource controls [2]. First, the datasource control gets all the data from the database(see Code 1), and then the databound control is responsible to sort the dataset and display only a small number of records enough to fill a page. For example, a dataset can contain millions of records, and a web page displays only 10 of these records. This approach poses two problems: (i) lots of data is transferred between the database server and the web server (in a multiserver deployment scenario which is dominant in the production environment)。 = orderBy。 DataSet ds = new DataSet()。 introduction of state in HTTP (session, cookies, hidden HTML controls etc.), data management, and the server controls which are arguably the most significant enabler of the rapid development. Though these mechanisms and server controls can significantly decrease the application’s “ time to market‖, at the same time they can reduce performance and scalability of the web application. Analysis of factors which influence the response time of web applications is an active area of research [1].In this paper, we demonstrate the importance of adding custom program logics to server controls in order to improve performance and scalability of web applications. Here we put emphasis on the data binding mechanism, that is, the mechanisms used to maintain and display data. The other mechanism, such as data updating, pag caching, data caching, state management etc. are left for future work. Here we address the following research questions: ? What is the impact of the paging mechanism on the response time? ? What is the impact of indices on response time when sorting and paging the results? ? What is the dependence of the response time on the number of database records? ? What are the scenarios when it is better to use server controls? When is it better to use custom stored procedures for fetching, sorting and paging the results? The outline of our paper is as follows. In Section 2 we are explaining the basics of data binding in applications, how paging is used to cut the expenses for fetching and displaying data, and sorting the data by some field. In Section 3we are explaining our test environment and the testing approach. Test environment is sued to measure the response time of various pages which implement various methods for data fetching and display. In Section 4 we explain the results from the tests. The Section 5 concludes the paper and outlines further research 2. DATA BINDING IN APPLICATION When using databound control like GridView to display the data from a database, the fastest way is to bind the databound control with a datasource control, which connects to the database and executes the queries. When using this scenario, the datasource control automatically gets data from the database server [2] and displays it in the databound control. Datasource control gets the data from the database server after the event in the page life cycle [3] Figure 1. Communication between a databound control and a database through a datasource control This is the code that is used for the datasourcecontrol to bind with the database .asp:SqlDataSourceID=SqlDS1runat=serverConnectionString=%$ ConnectionStrings:tdbConn%SelectCommand=usp_autoDataBinding SelectCommandType=StoredProcedure/Following code connects a GridView control with the datasource control.asp:GridView ID=GridView1 DataSourceID=SqlDS1 … Columnsasp:BoundField DataField=ID HeaderText=ID SortExpression=ID …/ ? \ Another approach to display the data in a databound control is to get the data in the Page Loadevent, store it in a dataset object, and then bind the databound control to the dataset. We do not expectsignificant differences in execution time between the two scenarios, since the reasons for the slow response times (significant amounts of transmitted data, no use of database indices etc.) exist in both scenarios. Following code shows how the GridView control is populated in the Page Load method. SqlConnection connection = new SqlConnection(connString)。 data paging and sorting on web server。它需要較少的時(shí)間來(lái) fetchthe記錄,然后發(fā)送到 將 bedisplayed的記錄。當(dāng)排序和分頁(yè)與非聚集索引上做一個(gè)字段類似的改進(jìn)得以實(shí)現(xiàn)。沒(méi)有加入在表 TestTable的索引和記錄之間進(jìn)行,因此,執(zhí)行時(shí)間是非常短的第一部分。 SQL排序和分頁(yè) 從代碼 2第二個(gè) SELECT語(yǔ)句在第 4節(jié)之前提到的問(wèn)題是可以解決 的 storeprocedure這個(gè)修改: CREATE TABLE t(x INT) SET ROWCOUNT PageSize INSERT INTO t SELECT [int] FROM testTable WHERE [int] LastID ORDER BY [int] ASC SELECT testTable.* FROM t LEFT JOIN testTable ON t.[x] = testTable.[int] 代碼 3。當(dāng)記錄在表中的數(shù)量較少(如 500,000)和聚簇索引是在 文本框 中,則因?yàn)橥ㄟ^(guò) ID和 輸入框 排序時(shí),只有一組響應(yīng)時(shí)間內(nèi)存消耗是足夠小,不會(huì)觸發(fā)虛擬內(nèi)存的使用情況。圖 9 圖 12示出了響應(yīng)時(shí)間之間的關(guān)系平均超過(guò) 500試驗(yàn)和表中的記錄的數(shù)量 測(cè)試表 的。我們重復(fù)表中的一個(gè)不同數(shù)目的記錄的測(cè)量值: , , 記錄。在我們的測(cè)試環(huán)境中, SQL服務(wù)器開(kāi)始使用虛擬內(nèi)存時(shí)記錄在記錄數(shù)大于 820,000 ( 18,000第一頁(yè) 10條記錄每個(gè)被跳過(guò))大。因此, SELECT語(yǔ)句排序,并返回一個(gè)更大的數(shù)據(jù)集,并在需要其執(zhí)行的時(shí)間增加 。這意味著,有兩個(gè)不同的群體在代碼 2中的 SQL 存儲(chǔ)過(guò)程時(shí)的反應(yīng)。索引的存在對(duì)當(dāng)排序和分頁(yè)在 1 SQL存儲(chǔ)過(guò)程完成的 Web服務(wù)器上的響應(yīng)時(shí)間沒(méi)有影響。 圖 6中的表 測(cè)試表 資料是由聚集的 ID和字段 輸入框 和 文本框 有非聚集索引。圖 5顯示的結(jié)果時(shí),排序和分頁(yè)使用 SQL存儲(chǔ)過(guò)程中代碼 2完成在數(shù)據(jù)庫(kù)服務(wù)器讀者應(yīng)該注意的是, 圖 5采用圖 3不同時(shí)間尺度和圖四與前兩種方法相比,響