is it Possible to make a cleanup over the Database. I'm experimenting with a Website that was having to many Page Objects. So Admin slowed down horribly. Monitoring the Server with htop, it told me, that DB took lot of CPU Performance while choosing a Branch in the Sitetree. Now I try to make some imrovements by using the subsites module and expanding it with some Funktionality.
By deleting alle Pages from the Site in my Local Backup installation, I saw, that there are still many 1000 Pages Left in Database Table SiteTree (and all related tables).
I found some hints, that I can delete SiteTree_versions to delete the history, but what about SiteTree and SiteTree_Live? How do I investigate, which Rows are already deleted, and why are they left in the Tables?
So I'm one step further. When in Backend on Page Tree and selcting on Show: "All pages, including deleted", I see lots of orphaned Pages. Some of them are in Hirarchie, some are not, some are selectable, some throw errors, but there is one thing they all have in common. I can't delete them. The only Possibility is to restore them. I tried to reengeneer, how the sql statement is build to get all these orphaned Page IDs, but without success. Maybe someone can help me here by giving me the statement to return all orphaned Pages (or the statement, to return all IDs of Pages that are not deleted, to try it from the other side). This will help me, to write a tidy script that is cleaning my Database.