SQL Server Performance

Query Performance

Discussion in 'SQL Server 2008 General DBA Questions' started by ismailadar, Nov 1, 2010.

  1. ismailadar New Member

    hi all,
    I wonder about a query performance issue. I have two ways to write query. and i do not dedice which way is better.
    Firstly i can use case when structure for eg :
    ProcType, case ProcType
    When 1 Then 'Low'
    When 2 Then 'High'
    When 3 Then 'None'
    When 4 Then 'Other'
    From tabel
    On the other hand i can hold proctypes in a table and i can use Inner join.
    Which way is better? and why?
    thanx in advance
  2. Adriaan New Member

    Set up the extra table, create the two query statements, and compare (1) the execution plans, and (2) the timings
  3. FrankKalis Moderator

    I would expect the CASE expression to be faster than an additional table. However, this is not all about performance. If these handful 1/2/3/4 values are "almost static" and are unlikely to change, I would use the CASE. However, if there is a good chance that this enumeration will be changed, expanded, etc... I would go for the extra table. At the end of the day, these SQL database systems are highly optimized for tables and JOIN operations.
  4. ismailadar New Member

    thanx for your replies and ideas

Share This Page