On Wed, Aug 17, 2005 at 11:57:52 -0700,
Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com> wrote:
> Richard Huxton wrote:
> >
> >While the other answers all do their job, and in one go too, I'd be
> >surprised if you found anything faster than:
> >
> >SELECT myval FROM mytable WHERE myval > 1234 ORDER BY myval LIMIT 1
>
> Really? Aren't most things with ORDER BY O(n*log(n))?
No. Index lookups are O(log(n)). And you need to do only a constant number
of index lookups (2 or 4 depending on whether the values are unique).