select * performance question

This is a discussion on select * performance question within the MySQL Database forums, part of the Database Forums category; For a moderately busy website (few hundred queries per second), would there be noticeable performance difference between using: select * from ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-17-2006
Chad
 
Posts: n/a
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

Reply With Quote
  #2 (permalink)  
Old 12-17-2006
strawberry
 
Posts: n/a
Default Re: select * performance question


Chad wrote:
> 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


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..."

Reply With Quote
  #3 (permalink)  
Old 12-18-2006
petersprc
 
Posts: n/a
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/featu...le.php/1382791

Chad wrote:
> 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


Reply With Quote
  #4 (permalink)  
Old 12-18-2006
Willem Bogaerts
 
Posts: n/a
Default Re: 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'


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

--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Reply With Quote
  #5 (permalink)  
Old 12-18-2006
Jerry Stuckle
 
Posts: n/a
Default Re: select * performance question

Chad wrote:
> 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
>


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.
jstucklex@attglobal.net
==================
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:22 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0