How does Calendar Provider store instances of infinitely repeating Events?

Azzam Alsharafi :

In Calendar Provider there are multiple data tables, there's the Events table, which store details of individual Events, and there's the Instances table, which store the start and end time for each occurrence of an Event.

My question is:

How exactly are occurrences stored in the Instances table, like how could the table store every occurrence for an Event if the Event is repeating everyday forever? It would need infinite number of rows in the table, and also wouldn't this require much storage space? An Event that repeats everyday for one year would have 365 entries in the table, so isn't it a waste to store every occurrence of an Event?

Константин Осипов :

When you create a recurring event without end date, the provider expands it to fill your calendar for at least a year. If you scrolled your calendar down for more than a year, it will expand the event to the last date viewed.

Yes, it is quite inefficient in theory, but not so bad in practice. In my tests, a daily event scheduled for about 5 years took about 150KB in the database size (1858 rows). A weekly event - 30 KB (266 rows).

This is not an issue for a normalized database with indices even on low-end devices.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=7070&siteId=1