From f32cdb7d899aecc9feef20262afdd14d6ab197b7 Mon Sep 17 00:00:00 2001 From: LDA Date: Sat, 10 Aug 2024 23:58:41 +0200 Subject: [PATCH] [MOD/WIP] Mark listing transactions as readonly May want to sprinkle in "hinting" on the nature of operations done the database, which could allow LMDB to deal with those far more efficiently (for example, a read-only transaction can just be done as soon as the JSON itself is parsed out, as we don't really need the former anymore!) --- src/Db/LMDB.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Db/LMDB.c b/src/Db/LMDB.c index 3e35695..ff56fba 100644 --- a/src/Db/LMDB.c +++ b/src/Db/LMDB.c @@ -464,7 +464,9 @@ LMDBList(Db *d, Array *k) pthread_mutex_lock(&d->lock); - if ((code = mdb_txn_begin(db->environ, NULL, 0, &txn)) != 0) + /* Marked as read-only, as we just don't need to write anything + * when listing */ + if ((code = mdb_txn_begin(db->environ, NULL, MDB_RDONLY, &txn)) != 0) { /* Very bad! */ Log(LOG_ERR,