Re: Is faster use MIN function or TOP 1 with ORDER BY
From: Wayne Snyder (wsnyder_at_computeredservices.com)
Date: 04/21/04
- Next message: Wayne Snyder: "Re: identity is missing sequential in SQL"
- Previous message: Hari: "Re: BCP Utility"
- In reply to: Checco: "Is faster use MIN function or TOP 1 with ORDER BY"
- Next in thread: David Portas: "Re: Is faster use MIN function or TOP 1 with ORDER BY"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 21 Apr 2004 09:41:46 -0400
You should check the query plan for both, but I would suspect that if there
is an index on myfield, that nothing would be any faster than Min(),,,
although the optimizer might be smart enough to treat the top 1 order by
like a min, but i really doubt it.
-- Wayne Snyder, MCDBA, SQL Server MVP Computer Education Services Corporation (CESC), Charlotte, NC www.computeredservices.com (Please respond only to the newsgroups.) I support the Professional Association of SQL Server (PASS) and it's community of SQL Server professionals. www.sqlpass.org "Checco" <anonymous@discussions.microsoft.com> wrote in message news:32DB8F40-37A0-4E00-8A21-38E643C530CB@microsoft.com... > I should select the min value from a big table. Is better to use > SELECT MIN(MYFIELD) FROM MYTABLE > or > SELECT TOP 1 MYFIELD FROM MYTABLE ORDER BY MYFIELD > > thanks
- Next message: Wayne Snyder: "Re: identity is missing sequential in SQL"
- Previous message: Hari: "Re: BCP Utility"
- In reply to: Checco: "Is faster use MIN function or TOP 1 with ORDER BY"
- Next in thread: David Portas: "Re: Is faster use MIN function or TOP 1 with ORDER BY"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|