hi all I want to create a table with a long varchar column, maybe it's the url. according to dns spec, the url's max length is fixed. but I have to deal with url having long params such as a.html?q=aaaaaaaaaaaaaaaaaaaaaaaaaaaa&fl=bbbbbbbbbbbbbbbbbbbbbbbb.... I want the url is unique when inserting it. I googled and found http://stackoverflow.com/questions/6800866/how-to-store-urls-in-mysql this post suggests use md5 of url. But in theory, there will be conflict that two different urls will have the same md5(even it's probablitiy is very small). I want to a absolute correct solution. one method i can come up with is using select ... for update 1. begin transaction 2. select url from tb where md5='xxxx' for update 3. if the url is not exist, insert into this url; else do nothing
also I need to set the transaction isolation to SERIALIZABLE
is this solution correct in multithread/process environment?
another method is using trigger to check whether the url exist. I don't know whether this method will be faster than previous one. how to ensure it's correctness in multithread environment?
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql
Nov 05
Dan Nelson Re: how to create unique key for long varchar?
Nov 05, 2013; 09:55
Dan Nelson
Re: how to create unique key for long varchar?
Nov 05
Rick James RE: how to create unique key for long varchar?
Nov 05, 2013; 21:04
Rick James
RE: how to create unique key for long varchar?
Nov 06
Li Li Re: how to create unique key for long varchar?
Nov 06, 2013; 10:56
Li Li
Re: how to create unique key for long varchar?
Nov 05
Michael Dykman Re: how to create unique key for long varchar?
Nov 05, 2013; 22:29
Michael Dykman
Re: how to create unique key for long varchar?
Nov 06
Li Li Re: how to create unique key for long varchar?
Nov 06, 2013; 11:33
Li Li
Re: how to create unique key for long varchar?
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!