Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

DevTools model generation is very slow


I am using the latest 3.x DevTools with Phalcon 3.1.2 and Wamp on Windows 7 64bit platform. The system has 3Gb RAM of which at least 1Gb is unused most of the time. The model generation takes a lot of time on using either of the methods - Scaffold or Model. The below code is the culprit. This code takes about 2.5 to 3 minutes for each table. I wanted to know if there is something wrong with my setup and if not, then can this be improved. This code seems to be generating foreign key references. This code is approximately on lines 241 to 262 of Model.php.

foreach ($db->listTables() as $tableName) {
    foreach ($db->describeReferences($tableName, $schema) as $reference) {
        if ($reference->getReferencedTable() != $this->options->get('name')) {

        $entityNamespace = '';
        if ($this->options->contains('namespace')) {
            $entityNamespace = $this->options->get('namespace')."\\";

        $refColumns = $reference->getReferencedColumns();
        $columns = $reference->getColumns();
        $initialize[] = $this->snippet->getRelation(
            $this->options->get('camelize') ? Utils::lowerCamelize($refColumns[0]) : $refColumns[0],
            $entityNamespace . Utils::camelize($tableName),
            $this->options->get('camelize') ? Utils::lowerCamelize($columns[0]) : $columns[0],
            "['alias' => '" . Utils::camelize($tableName) . "']"

Thanks, Amal

edited Aug '17