Reputation: 163
I see lots of websites using slugs in URLs, like these:
[catalog-product id="179"] ---> [catalog-product slug="5oz-modelling-hammer"]
I'd like to know: compared to Int search, will String search in MySQL cause performance problems?
I know about indexed fields, but I wonder whether it will cause a problem because the query is run whenever a page is visited. And what is the best practice in table design or eve what are other back-end techniques I should know about?
Upvotes: 0
Views: 446
Reputation: 146450
This kind of question gets asked often in many forms:
require
or include
?echo $a . $b
or echo $a, $b
?DATE
or VARCHAR
?number % 2
or number & 1
?Computers as fast enough to make the answer irrelevant. You'd need to do those operations like 1 billion times per page load to make a difference and, in that case, you'd have bigger problems. Performance bottlenecks tend to be fairly obvious:
To sum up, whether to use IDs, slugs or both is basically a design decision that does not depend on how fast the server is.
Upvotes: 2