Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Aggregate function

Author  Topic 

kkiranvr
Yak Posting Veteran

54 Posts

Posted - 2010-08-27 : 19:12:14
Hi all,
I am using the select statement with MAX(id), MIN(id), COUNT(*) of a very big table and it is returning me the value in less than a second.

But surprisingly if i am using aggregate function MIN(id) in a seperate select statement it is taking upto 90 Seconds.

Here are the 2 statements I am running
SELECT MAX(ID),MIN(ID),COUNT(*) FROM A TABLE
-- Time consuming for this: less than a Second.

SELECT MIN(ID)FROM A TABLE-- Time consuming for this: Upto 90 Seconds.
Please clarify how it work internally when we call the select statement with Aggregate functions?



-Thanks N Regards,
Chinna.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-08-27 : 20:05:37
is ID indexed? i'll look for blocking 1st
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-28 : 01:06:43
are both statements fired on same table?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -