D
D
Dmitry Tarasov2020-06-11 19:08:59
MySQL
Dmitry Tarasov, 2020-06-11 19:08:59

How to quickly search host in url in mysql?

There is a table with a varchar field containing links. In different rows of the table, these links are of arbitrary length.
The table has 50k rows. I need to take a site.com domain from an arbitrary row in another table and very quickly find the domain in the url .

I do the search like this INSTR(`t1`.`url`, `bl_host`.`host`)

Adding an index on varchar gave a small increase, but this is not enough.

mysql8

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Gordinskiy, 2020-06-11
@DmitriyGordinskiy

Since it is known what part of the VARCHAR field will be used in the search, why not store it in a separate column?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question