AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Delete cascade postgres11/27/2023 ![]() ![]() The problem is then CDbSchema::quoteColumnName() adds more double quotes! Yii requires I include the double quotes when I specify the foreign key (because the schema stores the foreign keys with the double quotes). When I try to define relations in one of my models I run into trouble. In order to preserve case I must surround my tables and columns in double quotes. ![]() I have a database schema with a number of tables where both the table names and columns have mixed case. I am using Postgres 8.2.3 with PHP 5.2.8. (Table definitions were not included for brevity).I am new to this forum and Yii so please forgive me if I am reposting or reveal some ignorance about how Yii works. The constraint fk_item on item are one for each p* table, and the last two lines show the loop (though I don't understand what fk_dev is doing here as I'm not considering "devices" but "parts"). Trigger RI_ConstraintTrigger_a_24789 for constraint fk_dev on meta_p1: time=102571647.818 calls=53 Trigger RI_ConstraintTrigger_a_24769 for constraint fk_p1 on meta_p1: time=1285.033 calls=53 Trigger RI_ConstraintTrigger_a_25003 for constraint fk_item on item: time=0.182 calls=1 Trigger RI_ConstraintTrigger_a_24977 for constraint fk_item on item: time=48.029 calls=1 Trigger RI_ConstraintTrigger_a_24950 for constraint fk_item on item: time=16.547 calls=1 Trigger RI_ConstraintTrigger_a_24932 for constraint fk_item on item: time=0.142 calls=1 Trigger RI_ConstraintTrigger_a_24909 for constraint fk_item on item: time=0.318 calls=1 Trigger RI_ConstraintTrigger_a_24886 for constraint fk_item on item: time=0.269 calls=1 Trigger RI_ConstraintTrigger_a_24863 for constraint fk_item on item: time=0.278 calls=1 Trigger RI_ConstraintTrigger_a_24840 for constraint fk_item on item: time=0.333 calls=1 Trigger RI_ConstraintTrigger_a_24817 for constraint fk_item on item: time=0.351 calls=1 Trigger RI_ConstraintTrigger_a_24784 for constraint fk_item on item: time=50.434 calls=1 Trigger RI_ConstraintTrigger_a_24747 for constraint fk_item on item: time=33.225 calls=1 ![]() Trigger RI_ConstraintTrigger_a_24719 for constraint fk_item on item: time=0.232 calls=1 Trigger RI_ConstraintTrigger_a_24686 for constraint fk_item on item: time=0.116 calls=1 It meant that there would be a kind of n^2 search because of that loop (delete item => delete p1 and meta_p1 but delete meta_p1 also means delete p1), as shown on the EXPLAIN ANALYZE VERBOSE results: Delete on em (cost=0.42.8.44 rows=1 width=6) (actual time=0.100.0.100 rows=0 loops=1) Same when deleting a meta_p1: all p1 "contained" in the meta part were supposed to be deleted (which is a logic flaw, as an instance of p1 can also exist outside of meta_p1). Whenever an item is deleted, I want all parts p1, p2. (I might have reversed (1) and (n), I mean " (1) item has (n) meta_p1"). Which means we have a graph like this (mind the ASCII-art )) DEVICE ITEM
0 Comments
Read More
Leave a Reply. |