MrAdib
MrAdib

Reputation: 806

best mysql data type for storing barcode and searching in it

I use varchar for saving barcode in my database and the index is set for this field for better result in search. But the response time is a bit longer and we need to decrease the result time.

Upvotes: 1

Views: 4386

Answers (1)

pmoleri
pmoleri

Reputation: 4451

If you already have an index on that field, the query should be as fast as it can be. Take a look at this answer. Just make sure that MySQL is choosing that index.

Of course, if your barcodes are always of the same length you would be better off with a Char(N) datatype.

Upvotes: 2

Related Questions