I am creating a website that allows users to publish individual pages. This is similar to how jsbin.com allows you to create a public script URL that you are working on. The base MySQL table I'm working with now:
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 a column that contains a random string that the user will print at the end of the URL. So, for example, if a user posted a page with the hash value a1b2c3 , then the URL would be http://mysite.com/a1b2c3
OK, sorry that the description took so long. My question is: should I index the hash column? Will this make queries faster since I'm going to look up the strings by their hash value first?
In addition, I have another table that has a foreign key relationship to this. Does it make sense to work with it to associate it with a hash column?
Thanks for the help.
source share