The way we add new columns to tables can cause db to lock up
Bug #1450676 reported by
Robert Lyon
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Confirmed
|
Medium
|
Unassigned |
Bug Description
Currently when we want to add a column to an existing table we do something like this in lib/db/upgrade.php
$table = new XMLDBTable(
$field = new XMLDBField(
$field-
add_field($table, $field);
The problem is if the database is big it can cause things to lock up
Changing the above to a more direct:
execute_sql('ALTER TABLE {group} ADD COLUMN allowarchives SMALLINT NOT NULL DEFAULT 0');
seems to avoid this problem.
So this bug is here so we can find out why the current way is so resource intensive and/or what dangers there are doing it the more direct way.
Changed in mahara: | |
status: | New → Confirmed |
tags: | added: performance |
Changed in mahara: | |
importance: | Undecided → Medium |
To post a comment you must log in.
The current method programattically generates SQL statements, and then executes them.
So the very first step on this, should be to determine exactly what SQL statements it is generating. Then we can compare them with your raw SQL and see why the performance is so much worse.
Cheers,
Aaron