R
R
Relapse2015-01-20 03:07:01
MySQL
Relapse, 2015-01-20 03:07:01

Is it possible to use UNIQUE for VARCHAR?

Will it be critical to use UNIQUE for VARCHAR (the field will contain regular references)?
Or is it better to make a hash (char(32))?
The table will have ~300,000 - 500,000 entries.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Arman, 2015-01-20
@Arik

There is not so much data, it is always better to start with a simple understandable logic, and then, if necessary, optimize. Now UNIQUE(`url`), tomorrow it will be possible to add the `hashCRC32` INT field and store the hash of the string in CRC32 there, the unique index will need to be changed to UNIQUE(`hashCRC32`, `url`) - there will be a quick selection by the field with an integer and double index will not give duplicates.

M
Maxim Kudryavtsev, 2015-01-20
@kumaxim

It is a lot of the data is 20 million records....
In your case hang up on the UNIQUE + field on the same INDEX field and speed of selection/load on a DB will be comprehensible.

V
Vapaamies, 2015-01-20
@vapaamies

If the DBMS supports functional indexes (function-based), you can do it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question