PS4 or PS5 database rebuild allows safe troubleshooters to search the whole internal storage of the data. It detected issues like missing, duplicated, and corrupted files. Then it helps to clean up and create a new database. In short, PS4/PS5 Database Rebuild scans and cleans the whole drive.
If you want to know more: https://webknow.net/how-to-rebuild-database-in-ps4-ps5/