dbTalk Databases Forums  

Set MSSQL 2005 to Favor Returning First Rows of a Query

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Set MSSQL 2005 to Favor Returning First Rows of a Query in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
basis_consultant@hotmail.com
 
Posts: n/a

Default Set MSSQL 2005 to Favor Returning First Rows of a Query - 09-23-2010 , 08:28 AM






Hi,

I am not sure whether I am posting to the correct group; If not,
please tell
me which groups are better.

My experience has been mainly with Oracle. In Oracle (9i+) there is an
optimizer
mode name FIRST_ROWS (Now FIRST_ROWS_N), typically used in OLTP
environments.

It hints that the database should favor returning the first N rows of
a query
as soon as possible; The rest of the query can continue running in the
background.
Typically, this mode favors indexes over full-table scans.

The idea is that the user sees a result set quickly.

Is there something similar in MSSQL 2005? If so, any info or links
will
be greatly appreciated.



Thanks,
QZ

Reply With Quote
  #2  
Old   
Gert-Jan Strik
 
Posts: n/a

Default Re: Set MSSQL 2005 to Favor Returning First Rows of a Query - 09-23-2010 , 03:40 PM






"basis_consultant (AT) hotmail (DOT) com" wrote:
Quote:
Hi,

I am not sure whether I am posting to the correct group; If not,
please tell
me which groups are better.

My experience has been mainly with Oracle. In Oracle (9i+) there is an
optimizer
mode name FIRST_ROWS (Now FIRST_ROWS_N), typically used in OLTP
environments.

It hints that the database should favor returning the first N rows of
a query
as soon as possible; The rest of the query can continue running in the
background.
Typically, this mode favors indexes over full-table scans.

The idea is that the user sees a result set quickly.

Is there something similar in MSSQL 2005? If so, any info or links
will
be greatly appreciated.

Thanks,
QZ
Yes there is. You can use the query hint OPTION (FAST <number_rows>), as
in:

SELECT my_column
FROM my_table
OPTION (FAST 10)

You can check Books Online (BOL) for more information.
--
Gert-Jan

Reply With Quote
  #3  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Set MSSQL 2005 to Favor Returning First Rows of a Query - 09-23-2010 , 03:40 PM



basis_consultant (AT) hotmail (DOT) com (basis_consultant (AT) hotmail (DOT) com) writes:
Quote:
I am not sure whether I am posting to the correct group; If not, please
tell me which groups are better.

My experience has been mainly with Oracle. In Oracle (9i+) there is an
optimizer mode name FIRST_ROWS (Now FIRST_ROWS_N), typically used in
OLTP environments.

It hints that the database should favor returning the first N rows of
a query as soon as possible; The rest of the query can continue running
in the background.
Typically, this mode favors indexes over full-table scans.

The idea is that the user sees a result set quickly.

Is there something similar in MSSQL 2005? If so, any info or links will
be greatly appreciated.
Add "OPTION (FAST n)" at the end of the WHERE clause. n is a number >= 1.

Whether it is a good idea, I don't know. It may be useful for something
that fills a form, as the user can get the first set of rows to look at
quickly. When you this hint, the otimizer will be less prone to use
stopping operators like hash joins.






--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.