This is a migrated thread and some comments may be shown as answers.

Time consuming if Query has a join

1 Answer 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rich
Top achievements
Rank 1
Rich asked on 24 Jul 2012, 09:44 PM
Hi,

I am using a Telerik RadGrid to display records I get from executing a stored procedure. The records that are returned from the stored procedure are stored in a DataSet which are then bound to the Grid's Data Source property using the following line of code

grid.DataSource=ds["Table"].DefaultView;
grid.DataBind

Depending on a few check boxes clicked on the page the stored procedure will either execute a join or execute a simple SQL query.

The simple query uses a SELECT * Statement
e.g.
SELECT * FROM Table1 WHERE Table1.Key=@Key

wheres the join statement uses a SELECT DISTINCT
e.g.
SELECT DISTINCT Table1.UserKey, Table1.UserName FROM Table1 INNER JOIN Table 2 on Table1.Key=Table2.ParentKey WHERE Table1.UserKey=@UserKey.

Both queries execute in under a second (we tested this SQL Server Management Studio). The SELECT * Statement returns around 300 records and SELECT DISTINCT returns around 200 records.

Even though the SELECT DISTINCT has fewer records it takes around 10-15 seconds more for the page to render than the SELECT * Statement.

We would really appreciate your feedback on this problem.

ASPX For the telerik grid is as follows

<telerik:RadGrid ID="dgSearch" CssClass="RadGrid RadGrid_CSMi" runat="server" Width="730px"

Font-Size="8pt" AllowSorting="True" AllowPaging="True" PageSize="5" AutoGenerateColumns="False"

EnableEmbeddedSkins="false" OnSelectedIndexChanged="dgSearch_SelectedIndexChanged">

<PagerStyle Mode="NextPrevAndNumeric" />

<AlternatingItemStyle BackColor="#C4E1FF" />

<MasterTableView Width="100%" DataKeyNames="AthleteKey">

<Columns>

<tec:GridButtonColumnWithFilteringSorting HeaderText="Full Name" UniqueName="FullName"

SortExpression="FullName" DataTextField="FullName" DataField="FullName" CommandName="Select"

ButtonType="LinkButton" />

<telerik:GridBoundColumn DataField="ID" HeaderText="ID" />

<telerik:GridCheckBoxColumn DataField="Active" HeaderText="Active" ReadOnly="True" />

<telerik:GridBoundColumn DataField="StatusPractice" HeaderText="Practice Status" />

<telerik:GridBoundColumn DataField="StatusGame" HeaderText="Game Status" />

<telerik:GridBoundColumn DataField="ReleaseDate" HeaderText="Release Date" />

</Columns>

</MasterTableView>

<FilterMenu EnableEmbeddedSkins="False" EnableImageSprites="False">

</FilterMenu>

</telerik:RadGrid>


Thanks,
CSMi

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 27 Jul 2012, 03:52 PM
Hi,

 The type of the SQL query should not affect the performs of the grid because the actual query is executed on the SQL server and this is irrelevant to the grid. The number of returned records is also relatively small so it too should not present any performance issues. One thing that I can suggest is to bind the grid using the NeedDataSource event (without explicitly calling DataBind) and pass the whole DataTable as a datasource to the grid (instead of the default view).

All the best,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Rich
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or