We upgraded from Sites 8.5 to Sites 9.1 and we noticed in some cases the items not getting cleared from the State Store DB. Can we clean up the data, if so what this the procedure?
Please refer to this link for more details on how to Scheduling a periodic cleanup of the State Store database
As Anand posted, you can schedule clean up of obsolete records from the state store database.
In upgrade scenarios, I would recommend the following link from the SDL KB article. There link details hotfixes, settings and the tuning information which might be useful to the issue that you are facing.
delete from EXECUTION; delete from EXECUTION_PROPERTY; delete from PIPELINE; delete from STEP; COMMIT;
The short answer to your question is to run something like the below on the state store database.