Cursor optimization tips

Explain in brief the cursor optimization tips.

The following are the tips for cursor optimization:

1. When the cursor is not needed, close the cursor.

2. Deallocate the cursor after closing it.

3. Fetch less number of rows.

4. Avoid triggers, because trigger executes whenever data gets updated, leads to overload of the system.

5. When the rows are not need to update, use the option FORWARD ONLY.

6. Use WHERE clause instead of HAVING clause unless it is essential.
Disadvantages/limitation of the cursor
Cursor requires a network roundtrip each time it fetches a record, thus consume network resources........
Define scrollable cursor
You can use keyword SCROLL to make cursor Scrollable.......
Temporary table VS Table variable
Table variable that can be used in stored procedures, functions and batches.......
Post your comment