|
72 | 72 |
|
73 | 73 | using namespace arangodb;
|
74 | 74 |
|
| 75 | +// helper class that optionally disables indexing inside the |
| 76 | +// RocksDB transaction if possible, and that will turn indexing |
| 77 | +// back on later in its dtor |
| 78 | +// this is just a performance optimization for small transactions |
| 79 | +struct IndexingDisabler { |
| 80 | + IndexingDisabler(RocksDBMethods* mthd, bool disableIndexing) |
| 81 | + : mthd(mthd), disableIndexing(disableIndexing) { |
| 82 | + if (disableIndexing) { |
| 83 | + mthd->DisableIndexing(); |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + ~IndexingDisabler() { |
| 88 | + if (disableIndexing) { |
| 89 | + mthd->EnableIndexing(); |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + RocksDBMethods* mthd; |
| 94 | + bool const disableIndexing; |
| 95 | +}; |
| 96 | + |
75 | 97 | RocksDBCollection::RocksDBCollection(LogicalCollection* collection,
|
76 | 98 | VPackSlice const& info)
|
77 | 99 | : PhysicalCollection(collection, info),
|
@@ -886,6 +908,9 @@ Result RocksDBCollection::insert(arangodb::transaction::Methods* trx,
|
886 | 908 | state->prepareOperation(_logicalCollection->cid(), revisionId,
|
887 | 909 | TRI_VOC_DOCUMENT_OPERATION_INSERT);
|
888 | 910 |
|
| 911 | + // disable indexing in this transaction if we are allowed to |
| 912 | + IndexingDisabler disabler(mthds, !hasGeoIndex() && trx->isSingleOperationTransaction()); |
| 913 | + |
889 | 914 | res = insertDocument(trx, documentId, newSlice, options);
|
890 | 915 |
|
891 | 916 | if (res.ok()) {
|
@@ -1441,6 +1466,10 @@ Result RocksDBCollection::removeDocument(
|
1441 | 1466 | blackListKey(key->string().data(), static_cast<uint32_t>(key->string().size()));
|
1442 | 1467 |
|
1443 | 1468 | RocksDBMethods* mthd = RocksDBTransactionState::toMethods(trx);
|
| 1469 | + |
| 1470 | + // disable indexing in this transaction if we are allowed to |
| 1471 | + IndexingDisabler disabler(mthd, !hasGeoIndex() && trx->isSingleOperationTransaction()); |
| 1472 | + |
1444 | 1473 | Result res = mthd->Delete(RocksDBColumnFamily::documents(), key.ref());
|
1445 | 1474 | if (!res.ok()) {
|
1446 | 1475 | return res;
|
@@ -1506,6 +1535,10 @@ Result RocksDBCollection::updateDocument(
|
1506 | 1535 | static_cast<uint32_t>(newKey->string().size()));
|
1507 | 1536 | rocksdb::Slice docSlice(reinterpret_cast<char const*>(newDoc.begin()),
|
1508 | 1537 | static_cast<size_t>(newDoc.byteSize()));
|
| 1538 | + |
| 1539 | + // disable indexing in this transaction if we are allowed to |
| 1540 | + IndexingDisabler disabler(mthd, !hasGeoIndex() && trx->isSingleOperationTransaction()); |
| 1541 | + |
1509 | 1542 | Result res = mthd->Put(RocksDBColumnFamily::documents(), newKey.ref(), docSlice);
|
1510 | 1543 | if (!res.ok()) {
|
1511 | 1544 | return res;
|
|
0 commit comments