Comment

Comment by tofflos

I liked the article, and I know this is nitpicking, but I disagree that creating an index is the best solution for eliminating the sequential scan. Hopefully the next article mentions it.

Just drop sort clause. Returning the user with the lowest id seems like an unusual use case.

Imagine searching for a name in a phone book and only finding the oldest person with that name, or the person with the lowest phone number.

More common cases are checking whether a user exists, which doesn't require a sort, or finding all the users with a particular name, which I guess could be paged using limit and offset.

parent tofflos 12 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton