• Bru Medishetty (11/22/2009)


    tho.pfaff (11/21/2009)


    ordinary queries grap the rows from the hard-disk, where the cpu needs more time to grap them. and erery time the sql-query is executed the a full table-scan must be performed to find the row.

    It is not always true that ordinary queries fetches the rows from hard disk.

    Regarding full table scan must be performed to find a row, that would be true if the company has a policy of no indexes and would never use an index ....:-) :-).

    Your assumption is wrong Tommy, a full table scan happens when there are no indexes and can be avoided by having appropriate indexes..

    What you said is true, but it seems to me that the question wasn't between a set-based query and cursor, but between a query in a for loop thus making it a RBAR operation rather than set-based.

    The question seems to spring from a commonly held belief that if you need a RBAR operation (you almost never do) you are better off "rolling your own" cursors by using a loop that by using a cursor. My testing of this has proven (to me) that if you really need RBAR operation, you are likely better off using a real cursor as opposed to "rolling your own."

    /*****************

    If most people are not willing to see the difficulty, this is mainly because, consciously or unconsciously, they assume that it will be they who will settle these questions for the others, and because they are convinced of their own capacity to do this. -Friedrich August von Hayek

    *****************/