erthink / libmdbx

One of the fastest embeddable key-value ACID database without WAL. libmdbx surpasses the legendary LMDB in terms of reliability, features and performance.
https://erthink.github.io/libmdbx/
Other
1.16k stars 110 forks source link

Updates which don't change anything producing dirty pages #230

Closed AskAlexSharov closed 3 years ago

AskAlexSharov commented 3 years ago

If put key/value pair which 100% match current in db - then update doesn't change anything (in terms of data), but mark page as dirty. So, it's possible to create large transaction which doesn't change any key/value pair.

It's not a big deal to check before update on APP side, just: 1. I'm not sure if it's bug/feature/performance tradeoff 2. I didn't know about this detail - but it looks important potential optimization of commit speed - then maybe need mention it in docs.

erthink commented 3 years ago

To avoid this the search-and-compare should be performed for each update operation. This is easy, but it will cost additional CPU cycles, and most importantly, such conditions (i.e. updates with the same data) is a fairly rare scenario. Therefore, when updating data, such a check is not done in the main execution path.

I don't think that I should improve anything, because the required behavior is easily implemented by a combination of mdbx_cursor_get() and mdbx_cursor_put(..., MDBX_CURRENT).

AskAlexSharov commented 3 years ago

right