Merge "Avoid linear scans of database tables" into main