You have several things working against you.
- You purchase the base model with a really slow 5400 rpm Hard Drive and only 8GB of RAM.
- You have install CleanMyMac X on you iMac, which does nothing but slow down your iMac.
- You upgraded macOS and there are background processes working on your Photos Library.
1) To improve the overall performance, your best bet is to get and run from an external SSD.
see > https://eshop.macsales.com/blog/55907-using-an-external-drive-as-your-startup-drive-part-1/
and > https://www.harddrivefailurerecovery.net/an-external-ssd-can-help-speed-up-your-old-imac/
2) You do not need AV-ware or Clean-ware on a Mac and CMM is considered junk-ware by 99.9% of the
experienced users around these parts. Best bet here, is to uninstall CCM as per the developers instructions,
then startup in Safe Mode followed by a normal restart.
3) If you have a large Photos Library, then it could take a day or so before the background "photoanalysisd
and photolibraryd" processes complete. Best bet here, is to just leave the iMac on for a couple of days, until
those complete and the activity subsides.