otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.58k stars 1.05k forks source link

[Suggestion] Save only modified houses #2437

Open slawkens opened 6 years ago

slawkens commented 6 years ago

So, currently, server is saving every house at the save.

It deletes all tiles from database and then inserts them again. What's the point of deleting/reinserting tiles that hasn't been modified? No at all.

It can be easily optimized by saving only those tiles that has been modified.

Like some kind of boolean flag in House::class - modified. Which changes when item is removed/deleted or house owner is changed.

And then making one big query only for those houses that has been modified.

This way, you can have real server save map in miliseconds, I did some test of it on some old 0.3 engine and it worked very well. Don't have the code anymore.

Before we implement this, we need to deeply rethink in what scenarios house should be updated/deleted. houses table can be updated every time, but more important for us is tiles table, which contains the most of the data.

Ochmar commented 4 years ago

This is good idea that with low effort can speed up this process by a lot. Can someone point actions that should trigger "hasChanged" on house tile?

  1. Item added (moved / conjured) on (to) tile
  2. Item deleted (moved / consumed / decayed) from tile
  3. Item added / deleted to container from tile
  4. Item charges changed What am I missing? I am not tibia player so for sure I am missing something.
Znote commented 4 years ago

Item modified (etc special attributes added or removed through a Lua script)

But cant this also be applied to player items/depot items? I'm sure over the course of a gameplay session, 95% of the loaded and saved items are not touched.

Isn't the house table also being "flushed" on reboot to potentially accomodate different map/house setup between startups?