Skip to content
This repository has been archived by the owner on Mar 25, 2022. It is now read-only.

Archive old numbers #40

Open
pitpalme opened this issue Oct 1, 2015 · 0 comments
Open

Archive old numbers #40

pitpalme opened this issue Oct 1, 2015 · 0 comments

Comments

@pitpalme
Copy link
Collaborator

pitpalme commented Oct 1, 2015

Maybe we should archive old/expired numbers, so performance of primary numbers table is kept high?

Additionally I don't know about reusage of numbers, so having it already stored with old timestamp might prevent it from being entered (in bad circumstances; unlikely, but possible).

One suggestion could be a regular cron job (maybe put into a shell skript):

sqlite3 --batch --cmd "BEGIN TRANSACTION;" lagesonr.db <<EOM
CREATE TABLE IF NOT EXISTS numbers_old(time TIMESTAMP NOT NULL, numbers VARCHAR(30) NOT NULL, user VARCHAR(10) NOT NULL, place VARCHAR(20) NOT  NULL, fingerprint VARCHAR(32) NOT NULL);
CREATE INDEX IF NOT EXISTS i_old_num ON numbers(number, fingerprint);
INSERT INTO numbers_old SELECT * FROM numbers WHERE time < date('now', '-30 days');
DELETE FROM numbers WHERE time < date('now', '-30 days');
COMMIT TRANSACTION;
EOM
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant