At the moment, koha-upgrade-schema indiscriminately runs updatedatabase.pl, regardless of whether or not the Koha instance actually requires a database upgrade. I've noted that running koha-upgrade-schema against a large number of instances (e.g. 50 instances) takes a couple of minutes. Jonathan has noted doing an upgrade will take 1.5 seconds, so 1.5 x 50 = would be 1.25 minutes. Jonathan and I agreed via email that koha-upgrade-schema should do a check similar to C4::Auth::_version_check but without using the ORM via C4::Context->preference() to avoid the overhead of loading the DBIC schema. In theory, koha-upgrade-schema should be able to spin through 50 instances in a fraction of a second, if none of them need database upgrades.
This isn't an urgent matter for me, so I'm not going to mark myself as the Assignee, but I may get to this at some point.
I'm noticing that updatedatabase.pl uses 100% CPU and runs for a while, so this is just annoying me too much now. Rather than make the change to koha-upgrade-schema though, I'm going to change updatedatabase.pl.
All we need to do is the following at the top of updatedatabase.pl: my $original_version = C4::Context->preference("Version"); my $code_version = $Koha::VERSION; if ( $original_version >= TransformToNum($code_version){ exit 0; } -- If the code version is the same or higher than the current database version, then there cannot possibly be any database updates to run, and we should exit immediately, rather than consuming 100% CPU for way too long by doing 23,000 lines of updates. This is a short-term solution as overhauling the database update system is the long-term solution.
*** This bug has been marked as a duplicate of bug 34088 ***