Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2012
    Posts
    4

    Unanswered: Random Select Procedure vs Application

    I need to randomly order the selected rows from my table. Is this better to do on the Application level or in a stored procedure using "orderby NewID()"?

    Which is faster? There will be about 100 rows returned with 10 columns.

    Thanks

  2. #2
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    I need to randomly order the selected rows from my table.
    _Please clarify - i do not understand what is wanted.

    Posting some sample data and the output when this sample is processed may help.

  3. #3
    Join Date
    Jun 2012
    Posts
    4
    I want to know which method of randomizing the query results would be faster:

    "Select * From MyTable Order By NewID()" - Database does all of the work

    or "Select * From MyTable" - and then randomize my results via C# - Shared work between database and application.

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    For the number of records you have, it is not going to make any difference.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  5. #5
    Join Date
    Jun 2012
    Posts
    4
    Does it matter that I may have tens of thousands of rows of data, but only 100ish will be selected?

    Just for my information, if I was selecting 100,000+ rows which would be better?

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    If you are select all records from a relatively small dataset, it is not going to matter.
    If you are selecting a random subset of records from a large dataset, then performing the selection on the database server using newid() will be faster than transferring the entire dataset over your network in order to perform this at the client.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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