For web pagination and multi-select items, should the selection be persisted across pagination?

In https://uxdesign.cc/designing-better-tables-for-enterprise-applications-f9ef545e9fbd there's a section called Multi-select breaks on pagination

Essentially, the idea is that if you can select multiple line items and you implement pagination, the selected items should be persisted.

Is that a good idea? If so, should the persistence be handled by the front-end code or the back-end code?

If the persistence is to be handled by the front-end code, does it mean that I need to load all the data upon first load? (I think that's suboptimal when the data > 10000 data rows or when the data is changed quite frequently)

Or i just need to simply store the selected items id in an array on the frontend?

Or every time an item is selected by a user, that piece of info is saved to the database?

There are pros and cons for each situation, so I hope to get some feedback on this.