The SQL patch just converts the old code(Qcodo 0.3.x) database structure to the new code(0.4.x) database structure. I did this by first examining a diff between the schema structure of both the codes. Then, I wrote queries to convert the old code schema to the new code schema and executed the same.
The query which takes about 15s is:
$objDocuments = ComplianceDocuments::QueryArray(
QQ::AndCondition(
QQ::OrCondition(
QQ::Equal(QQN::ComplianceDocuments()->UsersAsComplianceUser->UsersId, $objUser->Id),
QQ::In(QQN::ComplianceDocuments()->GroupsAsComplianceGroup->Groups->Id, QApplication::UserGroups($objUser->Id)),
QQ::Equal(QQN::ComplianceDocuments()->DomainsAsComplianceDomain->Domains->Id, $objUser->PrimaryGroup->Domain->Id)
),
QQ::Equal(QQN::ComplianceDocuments()->StatusTypeId, StatusType::Approved),
QQ::Equal(QQN::ComplianceDocuments()->IsDeleted, false)
),
$objCClauses
);
When I profile the code, the following is noticed(time in milliseconds):
Function InvocationCount TotalSelfCost TotalInclusiveCost
ComplianceDocumentsGen::InstantiateDbRow 2916 4051 10817
QMySqliDatabaseRow->GetColumn 85299 2634 7100
QType::Cast 34953 446 2608
QType::CastValueTo 34585 1070 1098
ComplianceDocumentsGen::InstantiateDbResult 35 1069 12171
QDateTime->__construct 8752 969 1793
php::mysql_query 530 444 444
php::DateTime->__construct 17506 310 310
UsersGen::InstantiateDbRow 140 279 462
QQNode->GetColumnAlias 1197 209 475
GroupsGen::InstantiateDbRow 250 209 383
QQueryBuilder->AddSelectItem 5036 174 233
QApplicationBase::SetErrorHandler 8751 169 189
QApplicationBase::RestoreErrorHandler 8751 164 165
php::date 8751 133 133
DashboardForm->Form_Create 1 111 15793
QMySqliDatabaseResult->GetNextRow 3637 102 182
UsersGen::QuerySingle 105 101 67
As we can see, InstantiateDbRow, QMySqliDatabaseRow->GetColumn and InstantiateDbResult are taking too much time?