| Efficiency: Num vs Char [message #455] |
Wed, 06 December 2006 15:40  |
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  |
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/
|
|
|