locked
HOrrible Performance on DetailsView with Linqdatasource on large table (8000+ records) RRS feed

  • Question

  • User-484343887 posted

    I have a details view which loads data froma linq datasource. The only crucial part is the <Where...> clause. It is set by a gridview's selectedvalue. It is very very very slow.

    I noticed that if I remove the *DataSoureID* property from the DetailsView everything is very fast again. But setting the DataSOurceID properyt when I have selected a record from the grid, does not work. It fills the DetailsView not with the record selected but the first record inthe database.

     Any ideas?

     --tolga

    Wednesday, October 15, 2008 1:52 PM

Answers

  • User-484343887 posted

    Marcin...thanks for you quick reply. Yes, it is a dynamic data web site, and yes scaffoldingalltables is set to true.

    I was able to find and eliminate the issue. This is the old (slow) code...it is the where clause in the detailsview linqdatasource

    <asp:ControlParameter ControlID="GridView1" Name="OffSiteItemSeq" Name="SelectedValue" />

    here is the new (fast) code...

    <asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableDelete="false" EnableInsert="true" EnableUpdate="true" ContextTypeName="DocumentStorageDataContext" TableName="OffSiteItems" AutoGenerateWhereClause="false" Where="OffSiteItemSeq == Guid(@OffSiteItemSeq)">

    <WhereParameters>

           <asp:SessionParameter DbType="Guid" Name="OffSiteItemSeq" SessionField="OffSiteItemSeq" />

    </WhereParameters>

    </asp:LinqDataSource>

    Now, what I do to populate the DetailsView is on the "Select" command of the grid I simply set the session variable *OffSiteItemSeq*.

    --tolga 

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 16, 2008 2:45 PM

All replies

  • User-797310475 posted

    Is this a Dynamic Data site? Is this using the default scaffold pages? Can you provide your code?

    Wednesday, October 15, 2008 2:24 PM
  • User-484343887 posted

    Marcin...thanks for you quick reply. Yes, it is a dynamic data web site, and yes scaffoldingalltables is set to true.

    I was able to find and eliminate the issue. This is the old (slow) code...it is the where clause in the detailsview linqdatasource

    <asp:ControlParameter ControlID="GridView1" Name="OffSiteItemSeq" Name="SelectedValue" />

    here is the new (fast) code...

    <asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableDelete="false" EnableInsert="true" EnableUpdate="true" ContextTypeName="DocumentStorageDataContext" TableName="OffSiteItems" AutoGenerateWhereClause="false" Where="OffSiteItemSeq == Guid(@OffSiteItemSeq)">

    <WhereParameters>

           <asp:SessionParameter DbType="Guid" Name="OffSiteItemSeq" SessionField="OffSiteItemSeq" />

    </WhereParameters>

    </asp:LinqDataSource>

    Now, what I do to populate the DetailsView is on the "Select" command of the grid I simply set the session variable *OffSiteItemSeq*.

    --tolga 

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 16, 2008 2:45 PM
  • User1641955678 posted

    You shouldn't have to use ViewState to get this working properly.  Going back to the original issue, was an item selected on the GridView when you get the slow perf?  Normally, the first item gets selected by default when you get to the page.  But if for some reason nothing is selected, then the DetailsView would bind to all the items, and that would indeed be super slow.

    David

    Thursday, October 16, 2008 3:59 PM
  • User-484343887 posted

    No, no item is selected by default. How can there? Both controls are loading and like you said, it seems like the details view is trying to bind to each record in the grid. Anyhow, I think the way it works now might be the best. I don't load data into the detailsview unless I really need to, taht is when a record in the grid has been selected.

    Thursday, October 16, 2008 8:45 PM