Monday, September 23, 2013

Use of Fast in SQL SERVER


Use of Fast in SQL SERVER:

Fast number-rows is a Query Hint. FAST number_rows: Specifies that the query is optimized for fast retrieval of the first number_rows. This is a non-negative integer. After the first number_rows are returned, the query continues execution and produces its full result set.

Suppose we have a table which has around 4 million records and you want to see all the data and you are in hurry. When you will fire a select query it will take around 1 or 2 minutes depends on the records in your table and the system performance. While it is executing query, you don’t want sit idle, you want to see some of the data from that table for inspection. Some of you will think that this can be done via TOP keyword but the problem with the TOP is that it will not return all the rows. So, in this situation FAST comes in picture. When you will fire a select query using FAST (n), the n rows will be displayed immediately and the query will execute remaining rows and displayed it.
EXAMPLE:  We have a Database called DBTest. This database is having a table called Employee. The employee table has 200024 rows. Let see how FAST (n) will help us:

No comments:

Post a Comment