You must Sign In to post a response.
  • Category: SQL Server

    Using cursors reduce performance ? if so why ?

    Hi all

    using cursors reduce performance ? if so why ?
  • #693501
    Hai Sathish,
    Can you please elaborate your question? In what situation the cursor is reducing the performance? is this windows application or web application or any other WPF or Silverlight application?
    may be the data is more on the page and due to this its taking time? Do you have written some code for changing the cursor?
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #693503
    I didnt face the situvation pawan. Just i got a doubt which is faster cursor or temporary table.If cursor is faster why viceversa

  • #693504
    Hi,

    Cursors will affect the performance so we need to be very careful while choosing cursor in your SQL query.

    Also their are different types of cursor available in SQL,
    For more information on syntax and types of sql server refer the link below,

    http://msdn.microsoft.com/en-us/library/aa258831(v=sql.80).aspx


    Thanks & Regards


    Bunty

  • #693514
    There are some advantages and disadvantages of cusror you can find below

    Advantages:
    - Cursors can provide the first few rows before the whole result set is assembled and fetched. without cursor, Queries can take long time to fetch data and show it on application
    - Cursors act as pointers to the underlying data exist in database, and so improve proper concurrency constraints
    ---------------------------------

    Disadvantages:
    - basically cursor requires a lot of resources and temporary storage so network is quite busy and get slow down
    - Cursor take a round trip to databse server, it will make overload and also make time consuming methods.
    ----------------------------------

    -When to use cursor
    Cursor may be slow down i accessing data as it takes round trip each time, so cursor should only be used when we need to access one row at a time.

    hope it helps

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #693517
    [Response removed by Admin. Read forum policies.]
    Regards,
    SonyShiva
    Never lose hope..You never know what tomorrow will bring

  • #693546
    Hai Sathish,
    Cursor is nothing but the memory area which holds the intermediate result and has the ability to process the row by row for the result.
    It is used when there is the requirement to process the row by row.
    If the data is more, it will difficult for cursor to maintain and updates th row by row data. So we can say that the cursor will give good performance when there is less data to process.
    We can use the cursor when there is the requirements of the validation which are not possible by using the constants like restrict the transaction on weekends, holidays and some other occasion.
    So these type of restriction can be done by using cursor.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.