Home » Performance » MySQL » Efficiency: Num vs Char
Efficiency: Num vs Char [message #455] Wed, 06 December 2006 15:40 Go to next message
bengoerz  is currently offline bengoerz
Messages: 6
Registered: November 2006
Junior Member
Hypothetically, what is the speed difference in evaluating a WHERE clause using a number vs. a character? For instance:
1. Select * WHERE key = "xyz"; vs.
2. Select * WHERE key = 1234;

The context is this: I want to generate a unique email message to a user on my website every time a new row is placed in a database under that username. This message should have a link directly to a page that will display the data from this row, such as:
http://mysite.com/display.php?row=98765
In order to keep this reasonably private, I want to generate a unique key as part of the row and include this in the URL sent in the email, such as:
http://mysite.com/display.php?row=98765&key=123
I anticipate activity spikes, so making the verification as efficient as possible is important.
Re: Efficiency: Num vs Char [message #457 is a reply to message #455 ] Thu, 07 December 2006 13:29 Go to previous message
Peter  is currently offline Peter
Messages: 405
Registered: August 2006
Senior Member
Super Guru
Lookup by integer is of course more efficient it is smaller index and comparison is faster. However for single row lookup difference may not be that large.

Also note you may use int/bigint in the database but pass some encrypted string to the client if you do not want people guessing IDs etc.


Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
Previous Topic:JOIN optimization
Next Topic:Where is the official InnoDB scalability patch?
Goto Forum:
  


Current Time: Sun Jul 5 22:28:21 EDT 2009

Total time taken to generate the page: 0.01065 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.