sql version with cache