Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5970207
benchmarkTruncate.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
benchmarkTruncate.php
View Options
<?php
// @codeCoverageIgnoreStart
require_once
__DIR__
.
'/../includes/Benchmarker.php'
;
// @codeCoverageIgnoreEnd
/**
* Maintenance script that benchmarks TRUNCATE versus DELETE queries.
*
* @ingroup Benchmark
*/
class
BenchmarkTruncate
extends
Benchmarker
{
public
function
execute
()
{
$fname
=
__METHOD__
;
$dbw
=
$this
->
getDB
(
DB_PRIMARY
);
$dbw
->
dropTable
(
'benchmark_perm_test'
,
$fname
);
$permTable
=
$dbw
->
tableName
(
'benchmark_perm_test'
,
'raw'
);
$dbw
->
duplicateTableStructure
(
$dbw
->
tableName
(
'page'
,
'raw'
),
$permTable
,
false
,
$fname
);
$dbw
->
dropTable
(
'benchmark_temp_test'
,
$fname
);
$tempTable
=
$dbw
->
tableName
(
'benchmark_temp_test'
,
'raw'
);
$dbw
->
duplicateTableStructure
(
$dbw
->
tableName
(
'page'
,
'raw'
),
$tempTable
,
true
,
$fname
);
$this
->
bench
(
[
'perm truncate'
=>
static
function
()
use
(
$dbw
,
$fname
,
$permTable
)
{
$dbw
->
query
(
"TRUNCATE $permTable"
,
$fname
);
},
'perm delete'
=>
static
function
()
use
(
$dbw
,
$fname
,
$permTable
)
{
$dbw
->
query
(
"DELETE FROM $permTable"
,
$fname
);
},
'temp truncate'
=>
static
function
()
use
(
$dbw
,
$fname
,
$tempTable
)
{
// Use a raw query not truncate() to avoid the "pristine" check.
// The other cases also use query() so that they will have comparable overhead.
$dbw
->
query
(
"TRUNCATE $tempTable"
,
$fname
);
},
'temp delete'
=>
static
function
()
use
(
$dbw
,
$fname
,
$tempTable
)
{
$dbw
->
query
(
"DELETE FROM $tempTable"
,
$fname
);
}
]
);
$dbw
->
dropTable
(
'benchmark_perm_test'
,
$fname
);
$dbw
->
dropTable
(
'benchmark_temp_test'
,
$fname
);
}
}
// @codeCoverageIgnoreStart
$maintClass
=
BenchmarkTruncate
::
class
;
require_once
RUN_MAINTENANCE_IF_MAIN
;
// @codeCoverageIgnoreEnd
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 14:19 (7 h, 6 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0c/56/1562b44d087d5f7b11363ef91915
Default Alt Text
benchmarkTruncate.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment