mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-39725 database: Add statistics collection functions
This commit is contained in:
parent
c36a2401ab
commit
814c9438a0
@ -2126,6 +2126,15 @@ abstract class moodle_database {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyze the data in temporary tables to force statistics collection after bulk data loads.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function update_temp_table_stats() {
|
||||
$this->temptables->update_stats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and returns true if transactions are supported.
|
||||
*
|
||||
|
@ -22,6 +22,7 @@
|
||||
*
|
||||
* - databases not retrieving temp tables from information schema tables (mysql)
|
||||
* - databases using a different name schema for temp tables (like mssql).
|
||||
* - databases that don't collect planner stats for temp tables (like PgSQL).
|
||||
*
|
||||
* Basically it works as a simple store of created temporary tables, providing
|
||||
* some simple getters/setters methods. Each database can extend it for its own
|
||||
@ -31,9 +32,6 @@
|
||||
* and the sql_generator, so both are able to use its facilities, with the final goal
|
||||
* of doing temporary tables support 100% cross-db and transparent within the DB API.
|
||||
*
|
||||
* Only drivers needing it will use this store. Neither moodle_database (abstract) or
|
||||
* databases like postgres need this, because they don't lack any temp functionality.
|
||||
*
|
||||
* @package core_dml
|
||||
* @copyright 2009 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@ -119,6 +117,17 @@ class moodle_temptables {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyze the data in temporary tables to force statistics collection after bulk data loads.
|
||||
* The database class detects all temporary tables and will automatically analyze all created tables
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function update_stats() {
|
||||
// By default most databases do automatic on temporary tables, PgSQL does not.
|
||||
// As a result, update_stats call immediately return for non-interesting database types.
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose the temptables stuff, checking for wrong situations, informing and recovering from them
|
||||
*/
|
||||
|
@ -29,5 +29,16 @@ defined('MOODLE_INTERNAL') || die();
|
||||
require_once(__DIR__.'/moodle_temptables.php');
|
||||
|
||||
class pgsql_native_moodle_temptables extends moodle_temptables {
|
||||
// I love these classes :-P
|
||||
/**
|
||||
* Analyze the data in temporary tables to force statistics collection after bulk data loads.
|
||||
* PostgreSQL does not natively support automatic temporary table stats collection, so we do it.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function update_stats() {
|
||||
$temptables = $this->get_temptables();
|
||||
foreach ($temptables as $temptablename) {
|
||||
$this->mdb->execute("ANALYZE {".$temptablename."}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user