Implement some more optdb queries