Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2006
    Posts
    57

    Unanswered: Querying the primary key for performance

    Hello, I am developing my first software product. I am trying to gain high database performance since this will be my main selling point.

    My database will contain tens of thoudands of rows and worried that if i make a query the reponse will be too slow to be prectical.

    so my question is:

    if i made one query on my database and it returned 10 results -- would'nt it be faster if I made 10 queries using the primary key?

    Will appreciate any responses.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Quote Originally Posted by Luke101
    if i made one query on my database and it returned 10 results -- would'nt it be faster if I made 10 queries using the primary key?
    Huh? Won't both methods use the primary key and/or indexes?
    If it's not practically useful, then it's practically useless.

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

  3. #3
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    Sending 10 queries when 1 will do is NOT a good idea. Round trips to the server is expensive.

    Also, sending 1 query to get more data than you need is also not a good idea. using bandwidth to transmit data you won't use is expensive, and client code is generally less efficient than sql server at filtering.

    In summary, it's best to write 1 query to fetch only the data you need, and no more.

  4. #4
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    also, tens of thousands of rows is cake for sql server. I deal with tables with tens and even hundreds of millions of rows daily.

    Just make sure you have your large tables indexed properly.

  5. #5
    Join Date
    Sep 2006
    Posts
    57
    Quote Originally Posted by jezemine
    also, tens of thousands of rows is cake for sql server. I deal with tables with tens and even hundreds of millions of rows daily.

    Just make sure you have your large tables indexed properly.

    thank you..thats what i needed to know..

Posting Permissions

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