MediaWiki
master
benchmarkTruncate.php
Go to the documentation of this file.
1
<?php
2
3
require_once __DIR__ .
'/../includes/Benchmarker.php'
;
4
10
class
BenchmarkTruncate
extends
Benchmarker
{
11
public
function
execute
() {
12
$fname = __METHOD__;
13
$dbw = $this->
getDB
(
DB_PRIMARY
);
14
15
$dbw->dropTable(
'benchmark_perm_test'
);
16
$permTable = $dbw->tableName(
'benchmark_perm_test'
,
'unquoted'
);
17
$dbw->duplicateTableStructure(
18
$dbw->tableName(
'page'
,
'unquoted'
),
19
$permTable,
20
false
,
21
$fname
22
);
23
24
$dbw->dropTable(
'benchmark_temp_test'
);
25
$tempTable = $dbw->tableName(
'benchmark_temp_test'
,
'unquoted'
);
26
$dbw->duplicateTableStructure(
27
$dbw->tableName(
'page'
,
'unquoted'
),
28
$tempTable,
29
true
,
30
$fname
31
);
32
33
$this->
bench
( [
34
'perm truncate'
=>
static
function
() use ( $dbw, $fname, $permTable ) {
35
$dbw->query(
"TRUNCATE $permTable"
, $fname );
36
},
37
'perm delete'
=>
static
function
() use ( $dbw, $fname, $permTable ) {
38
$dbw->query(
"DELETE FROM $permTable"
, $fname );
39
},
40
'temp truncate'
=>
static
function
() use ( $dbw, $fname, $tempTable ) {
41
// Use a raw query not truncate() to avoid the "pristine" check.
42
// The other cases also use query() so that they will have comparable overhead.
43
$dbw->query(
"TRUNCATE $tempTable"
, $fname );
44
},
45
'temp delete'
=>
static
function
() use ( $dbw, $fname, $tempTable ) {
46
$dbw->query(
"DELETE FROM $tempTable"
, $fname );
47
}
48
] );
49
50
$dbw->dropTable(
'benchmark_perm_test'
, $fname );
51
$dbw->dropTable(
'benchmark_temp_test'
, $fname );
52
}
53
}
54
$maintClass
= BenchmarkTruncate::class;
55
require_once RUN_MAINTENANCE_IF_MAIN;
$maintClass
$maintClass
Definition:
benchmarkTruncate.php:54
BenchmarkTruncate
Maintenance script that benchmarks TRUNCATE versus DELETE queries.
Definition:
benchmarkTruncate.php:10
BenchmarkTruncate\execute
execute()
Do the actual work.
Definition:
benchmarkTruncate.php:11
Benchmarker
Base class for benchmark scripts.
Definition:
Benchmarker.php:40
Benchmarker\bench
bench(array $benchs)
Definition:
Benchmarker.php:49
Maintenance\getDB
getDB( $db, $groups=[], $dbDomain=false)
Returns a database to be used by current maintenance script.
Definition:
Maintenance.php:1054
DB_PRIMARY
const DB_PRIMARY
Definition:
defines.php:28
maintenance
benchmarks
benchmarkTruncate.php
Generated on Thu Sep 28 2023 07:10:34 for MediaWiki by
1.9.1