phalcon-devtools
phalcon-devtools copied to clipboard
Scan the whole Database before generate one model
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 #1 SMP Debian 4.19.194-3 (2021-07-18) x86_64 PHP Version: 7.3.31-1+0~20210923.88+debian10~1.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
I read this relative snippet in src/Builder/Component/Model.php:166 Now I figured out that whole schema scan mainly serves to find relations of the table which need to be generated So I was considering to add some options like "--no-relation" to skip this whole schema scan ? Is this solution acceptable ?