To route requests on my website, I need to query the database to see if the first part of a URL matches a category for an item.
I have a request to /animals/dog/darktheme/. The category is 'animals', thus the
category_url in the mysql DB is
SELECT DISTINCT category_url FROM items WHERE '/animals/dog/darktheme/' LIKE CONCAT(category_url,'%');
This query will have to run for literally every page load of my site. I'm still in the planning stage, thus can change my design if need be.
Does this kind of query perform reasonably well? Let's say there's 10,000 items and 250 different
category_urls which are all like
Any tips on optimizing performance for this kind of query, or any better ways to do it, from the database/query perspective?