select query fix for DB infrastructure