Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Nakul Vachhrajani is a Technical Specialist & Systems development professional with iGATE. He holds a MCTS (SQL Server 2008: Implementation & Maintenance)
Browse by Tags · View All
#SQLServer 242
SQL Server 241
Administration 208
DBA 197
Tips 186
Development 186
T-SQL 181
#TSQL 179
Guidance 123
Tools and Utilities 112

Archive · View All
April 2011 14
March 2012 11
December 2011 11
March 2011 11
December 2012 10
October 2011 10
January 2011 10
January 2013 9
November 2012 9
October 2012 9

#0163–SQL Server 2012–Deprecated Features–Table Hint: FASTFIRSTROW-Msg: 321

May 24 2012 12:00AM by Nakul Vachhrajani   

Every version of SQL Server comes with a lot of optimizations to the database engine, and these changes require changes to the T-SQL syntax. New statements are introduced or modified and existing ones are dropped. Often table and query hints are optimized and modified in a similar fashion. These table and query hints are often used (in many cases, indiscriminately) to “improve the performance” of Microsoft SQL Server.

Let me start outright by saying that till date, I have never encountered the need to use the hint that we are about to discuss today.

Table v/s Query hints

Before going any further, I thought it best to revisit the simple method of identifying which is a table hint and which one is a query hint. For example, take the query below:

--Query for demonstration purposes only!
USE AdventureWorks2012
GO
SELECT *
FROM HumanResources.Employee WITH (NOLOCK) -- WITH (NOLOCK) is the table hint
WHERE OrganizationLevel = 3
OPTION (MAXDOP 1)                          -- OPTION (MAXDOP 1) is the query hint

The WITH (NOLOCK) hint is applied to the table/CTE/sub-query, i.e. a data source. Hence the name – table hint.

The OPTION (MAXDOP 1) is applied to the entire query, and hence the name – query hint.

[Edit]: You may also find the following post from Pinal Dave, a.k.a. “SQLAuthority” (B|T), useful in understanding Query Hints: http://blog.sqlauthority.com/2012/05/09/sql-server-quiz-and-video-introduction-to-basics-of-a-query-hint/

FASTFIRSTROW

According to SQL Server Books On Line, the FASTFIRSTROW is a table hint that helps the developer control the behaviour of the optimizer such that the optimizer,

  • Optimizes for overall minimum cost (minimum processing time/resources, etc), OR
  • Optimizes such that the time taken for the first row to be returned is minimized

The FASTFIRSTROW tells the optimizer that it is important to have the first row returned as fast as possible, allowing the application to return results to the users faster. You can see the difference by comparing the actual execution plans produced by the queries below:

--Query for demonstration purposes only!
USE AdventureWorks2008
GO
--Without the table hint
SELECT *
FROM HumanResources.Employee 
GO
--With the table hint
SELECT *
FROM HumanResources.Employee WITH (FASTFIRSTROW)
GO

image

OPTION (FAST n)

Running the above query in SQL Server 2012 results in the following error:

Msg 321, Level 15, State 1, Line 3
"FASTFIRSTROW" is not a recognized table hints option. If it is intended as a parameter to a table-valued function or to the CHANGETABLE function, ensure that your database compatibility mode is set to 90.

The message says it all – FASTFIRSTROW is no longer available, and if you would like to use it, the database compatibility level needs to be set to 90 (i.e.  SQL Server 2005).

The replacement available is not a table hint, but a new query hint – FAST number_rows. This query hint specifies that the query is optimized for fast retrieval of the first number_rows. This is a nonnegative integer. After the first number_rows are returned, the query continues execution and produces its full result set. SQL Server 2012 has given more flexibility to the developer/administrator because the table hint only optimized for the first row, whereas the query hint allows you to specify a custom number of first rows to optimize for.

As a replacement of FASTFIRSTROW, you can use OPTION (FAST 1).

--Query for demonstration purposes only!
USE AdventureWorks2012
GO
--Without the table hint
SELECT *
FROM HumanResources.Employee 
GO
--With the table hint
SELECT *
FROM HumanResources.Employee
OPTION (FAST 1);
GO

image

References:

Until we meet next time,

Be courteous. Drive responsibly.

Tags: #SQLServer, SQL Server, #TSQL, T-SQL, Development, Tips, Series, DBA, Administration, Best Practices, Denali


Nakul Vachhrajani
4 · 33% · 10690
11 Readers Liked this
Nirav Gandhi Liked this on 5/24/2012 12:07:00 AM
Profile · Blog · Facebook · Twitter
kingkong0924 Liked this on 5/24/2012 12:56:00 AM
Profile
Nakul Vachhrajani Liked this on 5/24/2012 1:05:00 AM
Profile · Blog · Facebook · Twitter
Olga Medvedeva Liked this on 5/24/2012 4:47:00 AM
Profile · Blog · Twitter
Guru Samy Liked this on 5/24/2012 6:46:00 AM
Profile · Blog
Madhivanan Liked this on 5/24/2012 6:58:00 AM
Profile · Blog · Facebook · Twitter
Nirav Liked this on 5/24/2012 7:49:00 AM
Profile · Blog · Facebook · Twitter
Hardik Doshi Liked this on 5/24/2012 9:26:00 AM
Profile · Facebook
Chintak Chhapia Liked this on 5/25/2012 7:12:00 AM
Profile · Blog · Facebook
Jacob Sebastian Liked this on 5/26/2012 1:32:00 AM
Profile · Blog · Facebook · Twitter
Manas Ranjan Dash Liked this on 5/26/2012 11:19:00 PM
Profile · Blog · Facebook · Twitter
11
Liked
 
0
Lifesaver
 
 
 
0
Incorrect



Submit

1  Comments  

  • commented on Aug 2 2012 10:42PM
    FrankComputer
    2904 · 0% · 2

Your Comment


Sign Up or Login to post a comment.

"#0163–SQL Server 2012–Deprecated Features–Table Hint: FASTFIRSTROW-Msg: 321" rated 5 out of 5 by 11 readers
#0163–SQL Server 2012–Deprecated Features–Table Hint: FASTFIRSTROW-Msg: 321 , 5.0 out of 5 based on 11 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]