Optimized lookup for Postgresql and MySQL. Falling back to read-ahead for others