2021-11-21, 05:45 PM
It looks like SQLite's optimization works on the database (schema) level but not the table level.
Currently, MyBB's using
And there's more. This function does fail when the
Actually the error was from the
Then, there are two things we can get:
1. SQLite's
2. As there would be any uncontrollable query [b]without running before the DB class execute
So I suggest to just remove the function body in SQLite and leave out SQLite's database optimization.
For future development, we could start thinking about SQLite's
My old suggestion was: since the function is intended to run over tables, we may pass SQLite's implementation for it and add another
Currently, MyBB's using
VACUUM
is working on tables rather than databases/schemas, which is wrong: https://github.com/mybb/mybb/blob/mybb_1...e.php#L923And there's more. This function does fail when the
VACUUM
query tries to closeCursor()
in https://github.com/mybb/mybb/blob/mybb_1...e.php#L924 . Actually the error was from the
VACUUM
itself. We can read the error using PDO's errorInfo()
and the error message states "cannot VACUUM - SQL statements in progress".Then, there are two things we can get:
1. SQLite's
VACUUM
works on database (schema), not current MyBB's using on table.2. As there would be any uncontrollable query [b]without running before the DB class execute
VACUUM
on the database, there would (nearly) always that error preventing the db engine to optimize the database.So I suggest to just remove the function body in SQLite and leave out SQLite's database optimization.
For future development, we could start thinking about SQLite's
VACUUM [...] INTO ...
to optimize the database and generate a new db file and replace the old db file with it.My old suggestion was: since the function is intended to run over tables, we may pass SQLite's implementation for it and add another
optimize_db()
function dedicated to SQLite for maintenance usage, such as Database Optimization and Database Backup. However, currently MyBB doesn't have database information such as database name stored in the DB object, it wouldn't be easy to implement such optimize_db()
function. It'd be better to defer this part to 1.9.