Set Index Priority Operation
-
In RavenDB, each index has its own dedicated thread for all indexing work.
By default, RavenDB prioritizes processing requests over indexing,
so indexing threads start with a lower priority than request-processing threads. -
Use
SetIndexesPriorityOperation
to increase or lower the index thread priority. -
Indexes scope:
Index priority can be set for both static and auto indexes. -
Nodes scope:
The priority will be updated on all nodes in the database group. -
Setting the priority can also be done from the indexes list view in the Studio.
-
In this page:
Index priority
Setting the priority will affect the indexing thread priority at the operating system level:
Priority value | Indexing thread priority at OS level |
|
---|---|---|
Low | Lowest |
|
Normal (default) | Below normal |
|
High | Normal |
|
Set priority - single index
// Define the set priority operation
// Pass index name & priority
const setPriorityOp = new SetIndexesPriorityOperation("Orders/Totals", "High");
// Execute the operation by passing it to maintenance.send
// An exception will be thrown if index does not exist
await store.maintenance.send(setPriorityOp);
Set priority - multiple indexes
// Define the index list and the new priority:
const parameters = {
indexNames: ["Orders/Totals", "Orders/ByCompany"],
priority: "Low"
}
// Define the set priority operation, pass the parameters
const setPriorityOp = new SetIndexesPriorityOperation(parameters);
// Execute the operation by passing it to maintenance.send
// An exception will be thrown if any of the specified indexes do not exist
await store.maintenance.send(setPriorityOp);
Syntax
// Available overloads:
const setPriorityOp = new SetIndexesPriorityOperation(indexName, priority);
const setPriorityOp = new SetIndexesPriorityOperation(parameters);
Parameters | ||
---|---|---|
indexName | string | Index name for which to change priority |
priority | "Low" /"Normal" /"High" |
Priority to set |
parameters | parameters object | List of indexes + Priority to set. An exception is thrown if any of the specified indexes do not exist. |
// parameters object
{
indexNames, // string[], list of index names
priority // Priority to set
}