4 ms·
If I address the sql table using the slug (let's say a slug is between 10 to 100 character), isn't it an overkill for performance instead of just looking for an
by myf01d 10y ago
If I address the sql table using the slug (let's say a slug is between 10 to 100 character), isn't it an overkill for performance instead of just looking for an int or bigint like in id or hash?
Maybe it won't be a difference for something like Redis (i.e. O(1) for any key) but it will be a performance hit for a sql containing hundreds of thousands of row, am I right?
- grzm 10y agoIf you have an index on the column, it shouldn't be an huge issue. You'd have similar issues if you had no index on the integer column. Of course, if you're really concerned about it, you can easily put together a test. I suspect other latencies in your app would be larger than those due to the difference between integer lookup and text lookup. But like I said: if you're highly sensitive to performance, you'll want to be measuring against your application, your stack, regardless of advice you might read about on the internet. If beautiful URIs are a priority, you can use a separate mapping table or service (memcache? Redis?) that maps the URI to a database ID. Of course, this adds latency/overhead as well. This could also give you flexibility in supporting multiple slugs for a single story.