Re: SUM() Taking Too Long

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Huiyong Lau (huiyong_lau_at_hotmail.com)
Date: 11/30/04


Date: Tue, 30 Nov 2004 13:00:08 +1100

Most likely the queries were using a different execution plans. Can you
post those execution plans?

Regards,
Huiyong

"Ian Smith" <Ian Smith@discussions.microsoft.com> wrote in message
news:273A0688-70AA-4C91-96CA-28A7567573E3@microsoft.com...
> I've got a UDF that executes the following query:
>
> SELECT SUM(dbo.AdjustedOrderTotal(tblOrders.ID))
> FROM tblOrders INNER JOIN tblPeople ON tblOrders.SoldToContactID =
> tblPeople.ID
> WHERE tblPeople.CompanyID = 1
>
> The problem is this query takes about 12 seconds to execute. When I remove
> the SUM() from the query (as in "SELECT
dbo.AdjustedOrderTotal(tblOrders.ID)
> FROM..."), the query executes almost instantly and returns two values. It
> shouldn't take 12 seconds to sum up two values.
>
> Does anybody have any idea why aggregating these results would cause such
a
> huge delay?



Relevant Pages

  • Re: Finally which ORM tool?
    ... Also, if you pass a variable to the query, the value the ... you have a linq query and by changing the variable's value, ... q is affected if I change foo AFTER this query and BEFORE execution. ... And it is a declaration, but one which captures the variables. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Finally which ORM tool?
    ... the session' method. ... able to execute the query by itself. ... has at EXECUTION time is used, ... That SHOULDN'T be important, simply because q LOOKS like a declaration, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Execution plan
    ... I have 191276 rows in table transportOrder, ... index on transportOrder for your query. ... But as you see from query plan, optimizer didn't use this index at ... Sometimes you have query which executes slow(no matter which execution ...
    (microsoft.public.sqlserver.programming)
  • Re: Finally which ORM tool?
    ... the session' method. ... they use the same mechanism as Linq to Sql does: ... Also, if you pass a variable to the query, the value the variable ... q is affected if I change foo AFTER this query and BEFORE execution. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: One Insert statement, no looping, creates 2 records?
    ... Is there any chance a distributed query is involved? ... you can see this when the first execution generates the ... >REALLY odd, tho, is that the debug display only shows once, even tho it's ... and the debug display ...
    (microsoft.public.sqlserver.programming)