Does redundant code effect Performance ?

  • Declare @a -- Same structure as B. In other words a temporary table with same structure as B

    (

    ID

    )

    Delete

    B

    From

    @a TempA

    inner join

    B

    on

    TempA.ID = B.ID

    -- This update will never execute as the common records have already been deleted .... My doubt

    -- being that will this piece of code effect the execution time of a stored proc

    Update

    B

    Set

    ID = TempA.ID

    From

    @a TempA

    inner join

    B

    on

    TempA.ID = B.ID

    -- In the following piece of code an unnecessary left outer join has been used ... will this piece of

    -- add to the execution time of the code even in case there are no rows common to the database

    -- there for the left outer join will result in all rows with B.ID as Null

    Insert into B

    (

    ID

    )

    Values

    (

    Select

    ID

    From

    @a TempA

    left outer join

    B

    on

    TempA.ID = B.ID

    Where

    B.ID is Null

    )

    My basic question being that even in case there are no rows common to the table will the performance of the query without the join be better than the performance of the query with the left join

  • In my view, redundant code

    a) any unnecessary code is a performance overhead. But to what extent it affects depends on the scenario. Think of this code being called from a webpage accessed by millions. The redundant code simply takes time, resource without achiving anything.

    b) redundaant code reduces readability of code and causes confusion and in turn maintenance becomes difficult

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply