Welcome to the world of database performance: never assume anything runs quickly. Since the
JDBC code for next() is pretty trivial, the problem most likely lies in the database itself. Most commonly, if you add proper indexes (use a database performance tuning tool if you don't know which indexes to ad) will solve your problem although if its completely stuck, it may be a key locking issue.