function mongodb_watchdog_ensure_indexes in MongoDB 6
Same name and namespace in other branches
- 7 mongodb_watchdog/mongodb_watchdog.install \mongodb_watchdog_ensure_indexes()
Create an index for the watchdog table.
This index is on <line, timestamp> instead of <function, line, timestamp>, because we write to this collection alot, and the smaller index on two numbers should be much faster to create than one with a string included.
3 calls to mongodb_watchdog_ensure_indexes()
- mongodb_watchdog_clear_log_submit in mongodb_watchdog/
mongodb_watchdog.admin.inc - Submit callback: clear database with log messages.
- mongodb_watchdog_enable in mongodb_watchdog/
mongodb_watchdog.install - Implements hook_enable().
- mongodb_watchdog_install in mongodb_watchdog/
mongodb_watchdog.install - Implements hook_install().
File
- mongodb_watchdog/
mongodb_watchdog.install, line 64
Code
function mongodb_watchdog_ensure_indexes() {
$collection = mongodb_collection(variable_get('mongodb_watchdog', 'watchdog'));
// Index for adding/updating increments.
$index = array(
'line' => 1,
'timestamp' => -1,
);
$collection
->ensureIndex($index);
// Index for admin page without filters.
$index = array(
'timestamp' => -1,
);
$collection
->ensureIndex($index);
// Index for admin page filtering by type.
$index = array(
'type' => 1,
'timestamp' => -1,
);
$collection
->ensureIndex($index);
// Index for admin page filtering by severity.
$index = array(
'severity' => 1,
'timestamp' => -1,
);
$collection
->ensureIndex($index);
// Index for admin page filtering by type and severity.
$index = array(
'type' => 1,
'severity' => 1,
'timestamp' => -1,
);
$collection
->ensureIndex($index);
}