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

Time consuming if Query has a join

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

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


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
SELECT * FROM Table1 WHERE Table1.Key=@Key

wheres the join statement uses a SELECT DISTINCT
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">


<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" />



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




1 Answer, 1 is accepted

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

 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,
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.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question