Professional Web Applications Themes

select * performance question - MySQL

For a moderately busy website (few hundred queries per second), would there be noticeable performance difference between using: select * from product where id = 5 vs select * from product where name = 'baseball' thanks for any info. happy holidays, chad...

  1. #1

    Default select * performance question

    For a moderately busy website (few hundred queries per second), would
    there be noticeable performance difference between using:

    select * from product where id = 5

    vs

    select * from product where name = 'baseball'

    thanks for any info.

    happy holidays,
    chad

    Chad Guest

  2. #2

    Default Re: select * performance question


    Chad wrote: 

    That'd be pretty easy to test for yourself! My guess is that there
    wouldn't be much difference - and probably less than the difference
    saying "SELECT *..." and "SELECT field1,field2,filed3,etc..."

    strawberry Guest

  3. #3

    Default Re: select * performance question

    Hi,

    You'd want to make sure the column you're selecting on is properly
    indexed. In your example, your table might be defined like so:

    create table t (
    id int primary key auto_increment
    name varchar(255) unique key
    );

    Then you could lookup records by id or by name, and have an index in
    either case. You then wouldn't see much difference in query speed in
    your app.

    Some more info:

    http://www.databasejournal.com/features/mysql/article.php/1382791

    Chad wrote: 

    petersprc Guest

  4. #4

    Default Re: select * performance question

    > For a moderately busy website (few hundred queries per second), would 

    You can test that using the BENCHMARK() function:
    http://dev.mysql.com/doc/refman/4.1/en/information-functions.html
    The test expression can also be a query.

    --
    Willem Bogaerts

    Application smith
    Kratz B.V.
    http://www.kratz.nl/
    Willem Guest

  5. #5

    Default Re: select * performance question

    Chad wrote: 

    It would depend several factors, including the size of the table and
    length of the string being compared.

    In general, an integer comparison will always be the fastest. String
    comparisons take longer. A single comparison of two short strings won't
    take significantly longer, but as the string gets longer and the number
    of rows increases (requiring more comparisons), the difference will grow.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    net
    ==================
    Jerry Guest

Similar Threads

  1. Performance Question
    By Mark A in forum Coldfusion - Advanced Techniques
    Replies: 7
    Last Post: March 14th, 08:08 PM
  2. Question about performance
    By rashadrivera webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: January 30th, 10:58 AM
  3. ADO Performance Question
    By MDW in forum ASP Database
    Replies: 2
    Last Post: December 7th, 04:10 AM
  4. performance question...
    By HomeBrewer webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 2
    Last Post: September 25th, 06:02 PM
  5. A performance question
    By hairybobby webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 1
    Last Post: August 5th, 11:06 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139