Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database: Provide pack mechanism to keep database small #566

Open
msinn opened this issue Jan 30, 2022 · 1 comment
Open

database: Provide pack mechanism to keep database small #566

msinn opened this issue Jan 30, 2022 · 1 comment

Comments

@msinn
Copy link
Member

msinn commented Jan 30, 2022

This issue is moved over from the core repo. The complete issue can be read over there: smarthomeNG/smarthome#216

The sqlite plugin have a pack mechanism which keeps the database small (like RRD files does). The database plugin does not have this mechanism and keeps all the values in the database.

To be able to have small databases (e.g. for embedded systems and maybe completely replace sqlite plugin) the database plugin should also have such a mechanism.

Different ideas exist

Reduce by aggregation: aggregate and pack values for different timespans to different details
Reduce by dumping/exporting: automatic export/dump function which exports data (e.g. into CSV files) and removes them > from database after export completed
Reduce by moving to history tables: make use of history tables (e.g. move everything older than one year into a log_YYYY table)
Reduce by removing "duplicates": duplicated values, eg same value in multiple records can be aggregated to one record
Reduce by remvoing: Simply delete data older the given amount of time
Reduce by max. amount of records: Only given amountof records will be kept in database, other ones will be removed
Reduce by kepping database size: calculate usage of each item and remove given percentage frkm all of them
Reduce by replacing details with inaccurates: replace details by calculating an inaccurate value for a set of values (e.g. only store changes for temperature without changes in floating point)
... other ideas?
Can be configured:

Globally in plugin configuration
On a per item basis
... other ideas

(leftover from #165)

@msinn
Copy link
Member Author

msinn commented Aug 29, 2023

Would the automatic packing be of value?

If setting maxage for the first time, I see a real value in packing the Database.

When deleting database entries periodically without packing, the space within the database is reused by new records. This would result in a database that just does not grow.

Packing after deleting records would result in a smaller database only for a small amount of time, since new records make the database grow again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants