Well, there are 2 sides to performance.
The first is the number of rows you fetch from the database.
The second is the size of the page you stream down to the client. If you
have to display 10K rows worth of data on a page all at once, obviously that
will take a long time to download, it will take a very long time for the
browser to parse and render the resulting HTML, not to mention the page will
be virtually unusable to the user.
Paging data using the PagedDataSource class resolves the second issue.
The first issue is not at all related to PagedDataSource, since that happens
before the paging is applied. By the time PagedDataSource is applied to a
datasource, obviously all the data has already been fetched - unless you
modify your SQL query, which you had not. So there is no way for it to help
there.
So, you are on your own regarding fetching only the relevant rows from the
database.
"Franz" <fr*******@i-hate-spam.com> wrote in message
news:ux**************@TK2MSFTNGP11.phx.gbl...
Does that mean my code is not performance-oriented?
Should I modify the query so that it only fetches the records needed?
"Marina" <so*****@nospam.com>
¼¶¼g©ó¶l¥ó·s»D:eA*************@TK2MSFTNGP09.phx.gb l... PagedDataSource presents a paged view of data. The data in reality is
always all there in your datatable/dataset. However, any object binding
to the data through the PagedDataSource, will only see one page of the
data at a time.
So, in the case of a datalist, the datalist will see just the 1 page of
data. It will only display that 1 page of data on the screen when it
binds to the PagedDataSource.
In the underlying datatable, however, all the records that were fetched
from the database are there.
This object is for data presentation purposes. It does not alter what
records actually get fetched from the DB. If you fetched 10K records, all
10K will be in memory. But if your page size is 20, the user will see 20
records at a time on the screen.
"Franz" <fr*******@i-hate-spam.com> wrote in message
news:u$*************@TK2MSFTNGP09.phx.gbl... Hi,
If my ProjectTable contains a lot of rows, each time I call the
following code, will all the rows be fetched? Or only those 5 records
for that page are fetched only?
/* -- code start -- */
OdbcConnection connection = new OdbcConnection("DSN=Whatever");
connection.Open();
string query = "SELECT * FROM ProjectTable";
OdbcDataAdapter dataAdapter = new OdbcDataAdapter(query, connection);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
PagedDataSource pagedDataSrc = new PagedDataSource();
pagedDataSrc.DataSource = dataSet.Tables[0].DefaultView;
pagedDataSrc.AllowPaging = true;
pagedDataSrc.PageSize = 5;
setPageIndex();
MyRepeater.DataSource = pagedDataSrc;
MyRepeater.DataBind();
/* -- code end -- */
Thanks,
Franz