Skip to content

Scan the whole Database before generate one model #1524

Description

@crimsonskyrem

Questions should go to https://forum.phalcon.io
Documentation issues should go to https://github.com/phalcon/docs/issues

Expected and Actual Behavior

Describe what you are trying to achieve and what goes wrong.

when I run phalcon to generate some model , like user_table in my database:

phalcon model user_table

Provide output if related

it will stuck in output and no more message

Phalcon DevTools (4.2.0)

I check the database , SHOW_PROCESSLIST shows the process are checking some other tables,

SELECT DISTINCT KCU.TABLE_NAME, KCU.COLUMN_NAME, KCU.CONSTRAINT_NAME, KCU.REFERENCED_TABLE_SCHEMA, KCU.REFERENCED_TABLE_NAME, KCU.REFERENCED_COLUMN_NAME, RC.UPDATE_RULE, RC.DELETE_RULE FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU LEFT JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON RC.CONSTRAINT_NAME = KCU.CONSTRAINT_NAME AND RC.CONSTRAINT_SCHEMA = KCU.CONSTRAINT_SCHEMA WHERE KCU.REFERENCED_TABLE_NAME IS NOT NULL AND KCU.CONSTRAINT_SCHEMA = DATABASE() AND KCU.TABLE_NAME = 'other_tables'

then this sql goes again to generate the model

SELECT DISTINCT KCU.TABLE_NAME, KCU.COLUMN_NAME, KCU.CONSTRAINT_NAME, KCU.REFERENCED_TABLE_SCHEMA, KCU.REFERENCED_TABLE_NAME, KCU.REFERENCED_COLUMN_NAME, RC.UPDATE_RULE, RC.DELETE_RULE FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU LEFT JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON RC.CONSTRAINT_NAME = KCU.CONSTRAINT_NAME AND RC.CONSTRAINT_SCHEMA = KCU.CONSTRAINT_SCHEMA WHERE KCU.REFERENCED_TABLE_NAME IS NOT NULL AND KCU.CONSTRAINT_SCHEMA = 'my_db' AND KCU.TABLE_NAME = 'user_table'

since my database has 800+ tables, it always take a long time to generate one model

I have no idea what is this scan running for, but when I generate only one model , it should scan only this table ?

Details

Phalcon DevTools (4.2.0)

  • Environment:
    OS: Linux debox 4.19.0-17-amd64 Easier installation on Linux and OSX #1 SMP Debian 4.19.194-3 (2021-07-18) x86_64
    PHP Version: 7.3.31-1+020210923.88+debian101.gbpac4058
    PHP SAPI: cli
    PHP Bin: /usr/bin/php7.3
    PHP Extension Dir: /usr/lib/php/20180731
    PHP Bin Dir: /usr/bin
    Loaded PHP config: /etc/php/7.3/cli/php.ini

  • Versions:
    Phalcon DevTools Version: 4.2.0
    Phalcon Version: 4.1.2
    AdminLTE Version: 3.0.1

  • Server: Nginx

  • Other related info (Database, table schema): Mysql5.7

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions