For webpage and multiple-selection elements, should the selection persist in paging?

At https://uxdesign.cc/designing-better-tables-for-enterprise-applications-f9ef545e9fbd there is a section called Multi-selection selections in pagination

Essentially, the idea is that if you can select several line items and implement paging, the selected items should persist.

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

If the persistence must be handled by the user code, does it mean that I must load all the data on the first load? (I think that is suboptimal when the data> 10000 rows of data or when the data is changed quite frequently)

Or do I simply need to store the identification of the selected elements in a matrix in the interface?

Or every time a user selects an item, that information is saved in the database?

There are advantages and disadvantages to each situation, so I expect to receive comments on this.