Forum Replies Created

Viewing 10 posts - 796 through 806 (of 806 total)

  • RE: UDF's vs Procs

    With regards to the Constant Scan, could that not be the actual call to the function and not what the function is doing?

    Example:

    If dbo.GetVehicleMakeByCode('410') <> ''

    ...

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • RE: UDF's vs Procs

    he he, the data changed... 🙂

    UDFCrispin

    UDFCrispin

    UDFCrispin

    >>> Point at which I updated it...

    UDFCrispin22

    UDFCrispin22

    UDFCrispin22

    The cool thing about the UDF is while 1 < 2 SQL is LOCKED!

    Someone want to sponser me a...

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • RE: UDF's vs Procs

    Hi,

    The problem is I can't "reuse" the variable.

    What I have is a loop getting vehicles, this function returns the vehicle type to me.

    If the table where normal, I could just...

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • RE: UDF's vs Procs

    ok.....

    Now I have a bit of time to play around with the differences.

    When I use the UDF, it does a Constant Scan. I told it to use the Clustered index...

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • RE: UDF's vs Procs

    ahhhh, the penny drops.

    Thanks for the help. I shall go read BOL and see what it says.

    From the apparent scans, a UDF does not use the index. Does this seem...

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • RE: UDF's vs Procs

    No luck, still runs faster.

    What I have noticed is the proc and UDF run the same, or close to, speed if only one is run. It's when you run...

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • RE: UDF's vs Procs

    Here are the only indexes on that table.

    CREATE CLUSTERED INDEX [IX_CCMakeModel] ON [dbo].[CCMakeModel]([MakeCode]) ON [PRIMARY]

    CREATE INDEX [IX_CCMakeModel_1] ON [dbo].[CCMakeModel]([ModelCode]) ON [PRIMARY]

    CREATE INDEX [IX_CCMakeModel_2] ON [dbo].[CCMakeModel]([CombinedModelSfx]) ON...

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • RE: UDF's vs Procs

    Here you go.

    Cheers,

    Crispin

    CREATE FUNCTION GetVehicleMakeByCode

    (

    @MakeCodeVarchar(20)

    )

    RETURNS Varchar(100) AS

    BEGIN

    Declare

    @vMakeNameVarchar(100)

    If IsNumeric(@MakeCode) = 1

    Begin

    Set @vMakeName = (Select Distinct MakeDesc From CCMakeModel Where MakeCode = @MakeCode)

    End

    Else

    Begin

    Set @vMakeName = (Select Distinct MakeDesc...

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • RE: UDF's vs Procs

    Greetings, Here's the test.

    I can see why it's faster but not sure why it would be...

    Crispin

    StmtText ...

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • RE: UDF's vs Procs

    Hi Antares686,

    Thanks for the reply.

    I did what you suggested and they all slowed down. BUT, the UDF's still ran much faster.

    Proc (100 times) was 1913 and UDF (100 times) was...

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

Viewing 10 posts - 796 through 806 (of 806 total)