/
Display database query runtime during deployment [5.2.2-B2]
Display database query runtime during deployment [5.2.2-B2]
In-Portal supports 2 ways of ensuring database schema/data is up to date with the current code:
- module upgrade executed via "/core/install.php" script from the Web
- module deployment scripts executed via "
php tools/run_event.php adm:OnDeploy ...
" command from CLI
The first way is user friendly and the second way is developer-friendly. Each way uses independent sets of SQL/PHP files.
On large projects, with large databases, it's crucial to be aware of deployment script run time. However current deployment script output doesn't contain it:
Deploying Module "Custom": Verifying Database Revisions ... OK Upgrading Database ... # r1: Initial Project Task (#TASK_ID) SELECT Name FROM `52x_Modules` ... OK (7) # r2: Another Task (#TASK_ID2) select sleep(3) ... OK (1) SELECT Version FROM `52x_Modules` ... OK (7) Importing LanguagePack ... OK Done with Module "Custom". Resetting Configs Files Cache and Parsed System Data ... OK Resetting Admin Console Sections ... OK Resetting ModRewrite Cache ... OK Refreshing Theme Files ... OK Dumping Assets ... OK
The same goes for the "/system/.restricted/project_upgrades.log" file:
[2020-12-23 16:18:48] === 123.456.789.123 === SELECT Name FROM `52x_Modules` ... OK (7) select sleep(3) ... OK (1) SELECT Version FROM `52x_Modules` ... OK (7)
Proposing to:
- display time next to shown executed database queries in "
*Time*: NNm MMs
" format - display time next to shown logged database queries in "
Duration: NNm MMs (from YYYY-MM-DD HH:MM:SS to YYYY-MM-DD HH:MM:SS)
" format - show executed revision name/number in the log like as on screen
Solution
In the "\DeploymentHelper::applyRevisions" method:
- measure each database query execution time
- display time next to shown executed database queries in "
*Time*: NNm MMs
" format - display time next to shown logged database queries in "
Duration: NNm MMs (from YYYY-MM-DD HH:MM:SS to YYYY-MM-DD HH:MM:SS)
" format - show executed revision name/number in the log like as on screen