How to remove last state from database

I am limiting recorder by excluding as many entities as possible. After purging the database, the last state for an entity is alway kept by design.

How can I remove these last states so that HA will nog find any state in the database?

Is there a SQL query, script or HA service I can call?