How to maintain fixed number of rows per foreign key?
It will be much more efficient to limit the SELECT and purge periodically.

If you had to maintain a hard limit of 10 for business requirements, what you'd do is define a trigger on history before insert or update or delete for each row that:


does a SELECT ... FOR UPDATE on the parent object_id to lock it, so it serves as a lock to prevent concurrent insert/delete of other history entries for the same object;
If this is an insert, counts rows for this object and gets the id of the oldest
If the number of entries will be increased to 11 by this insert, deletes the oldest row


Deadlocks can occur, so you need to be able to retry the whole transaction if there's a deadlock.