Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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 status=@status

 

 

which method is better in performance wise.

 

 

please suggest me 

new to this field 

 

 

 

 


  • 0

Advertisements


#2
azarl

azarl

    GeekU Admin

  • Community Leader
  • 25,310 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