What are the disadvantages of cursors?
1. Cursor results in a network roundtrip
2. Cursor requires more resources and temporary storage
3. Cursor results in more IO operations
4. 1 & 2
5. 1, 2 & 3
6. None
Showing posts with label Cursors. Show all posts
Showing posts with label Cursors. Show all posts
Question of the Day
Wednesday, 23 September 2009
Labels:
Cursors,
Question of the Day
T-SQL best practices - 1
Sunday, 20 September 2009
Hi All!...we decided to write some posts on the best practices in writing T-SQL,which we think helpful to the newbies.We will list three best practices each day for the next seven days and hope this series will be helpful to all the readers.So today's best practices tips are,
Document your database
–Use Extended properties of the table structures to document the database.
–Use tools to generate the documentation and correct where necessary
–Maintain the script for populating the extended properties.
Use Cursors only when
–You cannot find a set based solution in 4 Hours
–You want to utilize already existing logic in other SP
–You are writing a database maintenance task
Use STATISTICS IO ON
–This will reduce the logical reads
We need your comments on this post and share the best practices that you are using in the script(related to the above 3 techniques).
Labels:
Cursors,
T-SQL best practices,
Tips,
Tools
Top 10 SQL server Performance tuning tips - 6
Tuesday, 8 September 2009
Set Based Approach
Even though procedural approach is easier for most of the programmers,it (Use of Cursor, or, UDF to process rows in a result set) should be avoided when working with large result set.Most of the times cursors can be replaced by CTE(Common Table Expression). Avoiding Cursors with SQL Server 2005
Labels:
CTE,
Cursors,
Performance,
Tips
Top 10 SQL server Performance tuning tips - 5
Monday, 7 September 2009
Avoid cursors
Avoid using cursors.It may result in Deadlocks.Deadlocking occurs when two user processes have locks on separate objects and each process is trying to acquire a lock on the object that the other process has. During this kind of situation, SQL Server identifies the trouble and ends the deadlock by automatically choosing one process and aborting the other process, allowing the other process to continue.
Labels:
Cursors,
Performance,
Tips
Subscribe to:
Posts (Atom)