I came up with a solution: using special "md5" to deal with conflicts
steps to insert a url
1. insert into table(md5,url) values('md5 of url', url)
2. if get a duplicate entry for primary key
2.1 select md5,url from table where md5 like '%' for update
2.2 if url really exists, don't nee
The odds against the eventuality you are worried about are astronomically
high. Much serious work on the internet would fall apart were that not
true. Collision is simply not going to happen within the next several
hundred thousand years.
On Nov 5, 2013 9:59 PM, "Li Li" wrote:
> I prefer your s
I prefer your solution in that it's something like Optimistic Locking.
but the problem is that if I define md5 as unique key and there exists
2 different urls with the same md5. I can't insert the second url
anymore
On Tue, Nov 5, 2013 at 11:55 PM, Dan Nelson wrote:
> In the last episode (Nov 05)
The odds of a spurious collision with MD5 (128 bits) can be phrased this way:
If you have 9 Trillion different items, there is one chance in 9 Trillion that
two of them have the same MD5.
To phrase it another way, it is more likely to be hit by a meteor while winning
the mega-lottery.
>
In the last episode (Nov 05), Li Li said:
> 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=&fl=bb