I am creating a site that allows users to share specific pages to the public. It is similar to how jsbin.com let's you create a public url of the script you're working on. The basic MySQL table I am working with now is:
CREATE TABLE IF NOT EXISTS `lists` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`hash` varchar(6) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `hash` (`hash`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
The key
field is the column that holds the random string the user will type at the end of the URL. So, for example, if the user publicized there page with the hash value of a1b2c3
then the URL would be http://mysite.com/a1b2c3
OK, sorry the description took so long. My question is, should I index the hash column? Will this make queries faster, as I am primarily going to look rows up by their hash value?
Also, I have another table that has a foreign key relationship to this one. Does it make sense performance-wise to relate it to the hash column?
Thanks for the help.