Home » Performance » MySQL » Benchmark needed: WHERE id='$id' ... vs. WHERE id=$id
icon5.gif  Benchmark needed: WHERE id='$id' ... vs. WHERE id=$id [message #1573] Mon, 06 August 2007 11:19 Go to previous message
Spuerhund  is currently offline Spuerhund
Messages: 4
Registered: August 2007
Junior Member
Has somebody ever run a test to measure time differences of queries like:

SELECT foo FROM bar WHERE id='$id'

and
SELECT foo FROM bar WHERE id=$id

assumed that column id is an integer?

What i would like to know is how mutch these '...' influence the evaluation. I bet there is some difference (some CPU cycles needed for the string-to-integer cast) and i guess that it is really small compared to the time needed for seeking, ordering, joining, etc...

Nevertheless it could be interesting to know. Maybe the difference would be bigger when several expressions are combined like:

SELECT foo FROM bar WHERE a='$a' AND b='$b' AND c='$c' AND d='$d'

against
SELECT foo FROM bar WHERE a=$a AND b=$b AND c=$c AND d=$d


Anybody who can offer some statistics?

[Updated on: Mon, 06 August 2007 11:20]

Read Message
Read Message
Read Message
Read Message
Previous Topic:JOB: MySQL DBA - London Technology Company
Next Topic:major connection spike during "source dumpfile.sql"
Goto Forum:

  


Current Time: Sat Jul 4 18:18:39 EDT 2009

Total time taken to generate the page: 0.00940 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.