Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

which way is better in performance base

C# SQl

  • Please log in to reply

#1
nikmaluavk123

nikmaluavk123

    New Member

  • Member
  • Pip
  • 1 posts

Hi,

 

I want to show  data in a grid with certain conditions.

 

1. Method 

 

  I  wrote one sp  with if else condition  

 

  if(@type==1)

 

  select * from table where status=1

 

else if(type !=1)

 

  select * from table where status!=1

 

 

 

2. Method 

 

  i pass two  command parameter  

 @type 

@status

 

 

  and in sp i wrote

 

 if(@type=' '

 

 select * from table where [email protected]

 

 

which method is better in performance wise.

 

 

please suggest me 

new to this field 

 

 

 

 


  • 0

Advertisements


#2
azarl

azarl

    GeekU Admin

  • Administrator
  • 25,176 posts

Too many variables to answer this definitively but most likely be virtually nothing in it. If your software doesn't include a profiler in the debugger, I would write the time to a variable, loop method 1 a number of times and measure how long it takes each loop. Repeat for method 2.

In Pseudocode:

dim start as double = time()
dim count as integer = 0

do while count < 10000
      { call method 1}
        count = count+1
enddo while
print (time-start)/count

Repeat for method 2


  • 0

#3
DominickLo

DominickLo

    New Member

  • Member
  • Pip
  • 9 posts

If you are want to use condition once then first method is okay otherwise for multiple conditions you can use second method is effective. 


  • 0






Similar Topics


Also tagged with one or more of these keywords: C#, SQl

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP