-
Notifications
You must be signed in to change notification settings - Fork 51
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 optimize #291
base: master
Are you sure you want to change the base?
Database optimize #291
Conversation
I think we can only support searching of the old scheme, and implement a converting program for it. |
old scheme on sqlite, it stores timestamp in a string -- auto-generated definition
create table actions
(
id INTEGER
primary key autoincrement,
action_id INT not null
constraint fk_actions_action_id__id
references ActionIdentifiers
on update restrict on delete restrict,
time TEXT not null,
x INT not null,
y INT not null,
z INT not null,
world_id INT not null
constraint fk_actions_world_id__id
references worlds
on update restrict on delete restrict,
object_id INT not null
constraint fk_actions_object_id__id
references ObjectIdentifiers
on update restrict on delete restrict,
old_object_id INT not null
constraint fk_actions_old_object_id__id
references ObjectIdentifiers
on update restrict on delete restrict,
block_state TEXT,
old_block_state TEXT,
source INT not null
constraint fk_actions_source__id
references sources
on update restrict on delete restrict,
player_id INT
constraint fk_actions_player_id__id
references players
on update restrict on delete restrict,
extra_data TEXT,
rolled_back BOOLEAN not null
);
create index actions_action_id
on actions (action_id);
create index actions_by_location
on actions (x, y, z, world_id);
create index actions_object_id
on actions (object_id);
create index actions_old_object_id
on actions (old_object_id);
create index actions_player_id
on actions (player_id);
create index actions_source
on actions (source); |
On my real game server testing: old: 70% database size saved. |
Impressive!, but... |
I tried to run this sql on a 100k sample of our real data:
here's the top 10 result:
So we can implement a better "auto purge", that purges actions at the same locations over 100 times, this saves 97% data from our database. command:
|
My approach will be, add some new config options: If some actions, their all We can also encourage server admins to enable it since it almost never make you lose important data and save a lot of space. |
This PR optimize database size in various ways:
I finally found it very hard to support both old and new scheme. Currently only auto purge and muanually purge are supported. I made a
/ledger convert
command to convert data from the old scheme.