Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Posts
    76

    Question Unanswered: dense_rank vs. row_number

    what is better for performance when doing ranking in a cursor. Dense_rank or Row_number?

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    It all depends what you are trying to do. ROW_NUMBER will return incrementing number even if the values are equal

    Code:
    value  row_number
    1         1
    1         2
    2         3
    4         4
    Dense_RANK will put like value with the same number

    Code:
    value  row_number
    1         1
    1         1
    2         3
    4         4
    They will run in the same amount of time.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Nov 2003
    Posts
    76
    Thank you. I need incremental values so I'll go with row_number than.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,296
    I have not had good performance personally using row-number. When I switched it to a count instead I got a much quicker result set. Why? I am not sure. At the time I was just fiddling with the code to see what would happen.
    - The_Duck
    you can lead someone to something but they will never learn anything ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •