Ask any database user, what's the most irritating thing and most of them will answer "database maintenance". Almost every database, whether SQL or NoSQL, needs periodic maintenance. Free space needs to be collected so that, the database takes lesser space; statistics needs to updated so that the queries can be optimized; and so on. Users delay the maintenance activities till the transactional load reduces, at which times there are enough resources available for the maintenance tasks. A decade or two back, it was easier to take out time for such maintenance activities, but today, it has become increasing difficult to schedule maintenance activities because of increased load on database servers. Hence the "irritation" and users are expecting that database systems somehow reduce the maintenance requirement.
Is that possible? The answer looks tough. Periodic maintenance is a Universality. And surprisingly, our ancestors had acknowledged this fact. In Hindu scripture named "Bhagavad Geeta" (भगवद् गीता) or popularly known as only "Geeta" (गीता), a verse 4:7 goes thus
यदा यदा हि धर्मस्य ग्लानिर्भवति भारत | अभ्युत्थानमधर्मस्य तदात्मानं सृजाम्यहम् |
परित्राणाय साधुनां विनाशायच दुष्कृताम् | धर्मसंस्थापनार्थाय संभवामि युगे युगे ||
meaning: whenever धर्म (the force which sustains any system) is forced to sleep because of अधर्म (the opposite force), I am created (popularly translated as I take birth) to uphold the Good and to destroy the bad deeds. I happen (popularly translated as - I take birth) periodically in every age.
How easy is to see the parallel. If the free space be collected at the same time it is created or if the statistics would be updated at the time data gets added or changed, a database would not need any maintenance. But then the transactions would be slower, thus causing losses of money or time. Not only that, but the maintenance is sometimes more effective when done in bulk. If we were to clean few bytes every time those are freed, the total time for such tiny collections would be much larger than cleaning up huge chunks; same is the case with the statistics. So, in order to optimize the transactional throughput we leave the garbage uncleaned, or let the statistics be stale, thus creating "bad deeds", which eventually hinder the "Good", i.e. efficient operation of database. So, a maintenance task like Vacuum needs to "happen" periodically so as to destroy the "bad deeds" and help the "good". It shouldn't surprise us, the Hindus, that the sages put these words in the mouth of Krishna, who is the reincarnation of Vishnu, depicted as the force "maintaining" the Creation.
The Garbage or "bad deeds" are universal and they need to periodically cleaned. It is everywhere, from our bodies, houses, cities to computer systems. We need to keep maintenance windows for cleaning those periodically. Many scriptures describe these maintenance windows in various ways. Manusmriti (मनुस्मृती), which records the "commandments" of Hindus, explains those as periods of rest. The nights be used for daily maintenance, the period waning of moon (कृष्णपक्ष) be used for monthly maintenance, the period when Sun appears to move towards the South (दक्षिणायन) be used for yearly maintenance (Manusmriti verses 1:65-80). Old testament similarly employs the concept for Sabbath after every seventh day (Exodus 31:12-17, KJV), seventh month and seventh year and so on.
While we ponder over the universality and eternality of the scriptures, a finality strikes. While the database developers try to design their systems so that the they need smaller and smaller maintenance windows, it's important that the application developers too, design the applications such that the databases and other platforms used by the applications get enough maintenance windows; even the God needed to rest on the seventh day, databases are merely mortals!
Is that possible? The answer looks tough. Periodic maintenance is a Universality. And surprisingly, our ancestors had acknowledged this fact. In Hindu scripture named "Bhagavad Geeta" (भगवद् गीता) or popularly known as only "Geeta" (गीता), a verse 4:7 goes thus
यदा यदा हि धर्मस्य ग्लानिर्भवति भारत | अभ्युत्थानमधर्मस्य तदात्मानं सृजाम्यहम् |
परित्राणाय साधुनां विनाशायच दुष्कृताम् | धर्मसंस्थापनार्थाय संभवामि युगे युगे ||
meaning: whenever धर्म (the force which sustains any system) is forced to sleep because of अधर्म (the opposite force), I am created (popularly translated as I take birth) to uphold the Good and to destroy the bad deeds. I happen (popularly translated as - I take birth) periodically in every age.
How easy is to see the parallel. If the free space be collected at the same time it is created or if the statistics would be updated at the time data gets added or changed, a database would not need any maintenance. But then the transactions would be slower, thus causing losses of money or time. Not only that, but the maintenance is sometimes more effective when done in bulk. If we were to clean few bytes every time those are freed, the total time for such tiny collections would be much larger than cleaning up huge chunks; same is the case with the statistics. So, in order to optimize the transactional throughput we leave the garbage uncleaned, or let the statistics be stale, thus creating "bad deeds", which eventually hinder the "Good", i.e. efficient operation of database. So, a maintenance task like Vacuum needs to "happen" periodically so as to destroy the "bad deeds" and help the "good". It shouldn't surprise us, the Hindus, that the sages put these words in the mouth of Krishna, who is the reincarnation of Vishnu, depicted as the force "maintaining" the Creation.
The Garbage or "bad deeds" are universal and they need to periodically cleaned. It is everywhere, from our bodies, houses, cities to computer systems. We need to keep maintenance windows for cleaning those periodically. Many scriptures describe these maintenance windows in various ways. Manusmriti (मनुस्मृती), which records the "commandments" of Hindus, explains those as periods of rest. The nights be used for daily maintenance, the period waning of moon (कृष्णपक्ष) be used for monthly maintenance, the period when Sun appears to move towards the South (दक्षिणायन) be used for yearly maintenance (Manusmriti verses 1:65-80). Old testament similarly employs the concept for Sabbath after every seventh day (Exodus 31:12-17, KJV), seventh month and seventh year and so on.
While we ponder over the universality and eternality of the scriptures, a finality strikes. While the database developers try to design their systems so that the they need smaller and smaller maintenance windows, it's important that the application developers too, design the applications such that the databases and other platforms used by the applications get enough maintenance windows; even the God needed to rest on the seventh day, databases are merely mortals!