Query Optimization or Indexing
Query Optimization or Indexing
Query Optimization or Indexing
Query Optimization or Indexing
Query Optimization or Indexing
Query Optimization or Indexing Query Optimization or Indexing Query Optimization or Indexing Query Optimization or Indexing Query Optimization or Indexing Query Optimization or Indexing Query Optimization or Indexing Query Optimization or Indexing
Query Optimization or Indexing Query Optimization or Indexing
Query Optimization or Indexing
Go Back  Xtreme Visual Basic Talk > > > Query Optimization or Indexing


Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2014, 07:38 AM
mrkamran's Avatar
mrkamran mrkamran is offline
Centurion
 
Join Date: Jun 2003
Posts: 188
Question Query Optimization or Indexing


Hi,

I want to know query performance for my slow process, i have a scenario that i am generating loop from first employee to last employee to calculate status for each employee. i am using below code with three conditions whereas i have more than 10 conditions like this. My problem is that this process is going slow and slow after increasing employees. My tables have no index keys like primary. but there is GUID uniqueidentfier field in all tables. how can i speedup this process either by creating index or query optimization. Please tell me both how to index table or optimize query.

CountRows is a function which is executing given query and result give number of rows which query returns. i simply executing query with a given connection
like:
Code:
        Dim cmdCount As SqlCommand = New SqlCommand(sSQL, cn)

        Dim Res As Object = cmdCount.ExecuteScalar

        If IsDBNull(Res) Then
            CountRows = 0
        Else
            CountRows = Res.ToString
        End If

here is my process code:

Code:
 

If CountRows("Select Count(*) from TrainingDetail Where EmpCode='" & ECode &  "' And '" & FromDate & "' Between Cast(TrainingDate as Date) And Cast(TrainingEndDate as Date)") > 0 Then
                    Status = "T"
ElseIf CountRows("Select Count(*) from AbsentDetail Where EmpCode='" & ECode &  "' And '" & FromDate & "' Between Cast(AbsentDate as Date) And Cast(AbsentEndDate as Date)") > 0 Then
                    Status = "A"
ElseIf CountRows("Select Count(*) from AttendDetail Where EmpCode='" & ECode &  "' And '" & FromDate & "' Between Cast(aDate as Date) And Cast(eDate as Date)") > 0 Then
                    Status = "P"
....
....
....
....
Waiting for prompt reply

Thanks

Kamran
__________________
Thoughts determine what you want...Action determines what you get!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Query Optimization or Indexing
Query Optimization or Indexing
Query Optimization or Indexing Query Optimization or Indexing
Query Optimization or Indexing
Query Optimization or Indexing
Query Optimization or Indexing Query Optimization or Indexing Query Optimization or Indexing Query Optimization or Indexing Query Optimization or Indexing Query Optimization or Indexing Query Optimization or Indexing
Query Optimization or Indexing
Query Optimization or Indexing
 
Query Optimization or Indexing
Query Optimization or Indexing
 
-->