We can create a collection with WiredTiger engine and type=lsm
, but this feature is not mentioned in MongoDB documents:
db.createCollection(
"test",
{ storageEngine: { wiredTiger: {configString: "type=lsm"}}}
)
Once insert some documents and add an index, it seems WiredTiger really creates LSM files.
db.test.insert([
{ value: 1},
{ value: 2},
{ value: 3}
]) // Done in 16:04
db.test.createIndex(
{ value: 1 },
{ storageEngine: { wiredTiger: {configString: "type=lsm"}}}
) // Done in 19:59
$ ls -ltr
...
-rw-r--r--. 1 mongod mongod 16384 Jan 15 16:04 collection-0-1708338433081558809-000002.lsm
-rw-r--r--. 1 mongod mongod 16384 Jan 15 16:04 index-1-1708338433081558809.wt
-rw-r--r--. 1 mongod mongod 16384 Jan 15 19:59 index-3-1708338433081558809-000002.lsm
Collection and index value_1
seem like LSM-Tree, but index _id_
still seems like B-Tree.
How can I change engine type of index _id
?
Not an answer you would like to hear but it is not possible at the moment.
_id is quite special index. From https://github.com/mongodb/mongo/blob/73b456d5c059b17d1c7f0f8badb7c72391ee2173/src/mongo/db/catalog/index_key_validate.cpp#L74:
Specification validator for all indexes:
Specification allowed for _id index:
As you see you have flexibility to change nothing but name, collation, version etc. There is no
kStorageEngineFieldName
there.