News for hackers. Stuff that matters.
Re:Ask HN: Why can't we just use this idea for clean URLs wi... by myf01d on Friday November 04, 2016 @11:05PM (#12877927)
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?

Re:Ask HN: Why can't we just use this idea for clean URLs wi... by grzm on Friday November 04, 2016 @11:41PM (#12878027)
If 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.