问:
TimescaleDB extremely slow DELETE when having thousands of foreign key constraints
I have around 1500 hypertables with 150-200 columns and millions of rows each in a timescale database (~ 1TB size, compression disabled, currently ~20 chunks for each hypertable, v2.5). Basically, all of those hypertables contain sensor values from machines - one hypertable for each machine. Data gets read from incoming csv-files and is stored in the corresponding hypertable which is determined by the csv-filename. All the hypertables have a column "filename_id" (foreign key, ON DELETE CASCADE) which reference to an indexed ID column of a normal table "filename". This is necessary to keep track of the csv-files that have been read and stored into the database and also keep track of the filename from which each data record in a hypertable came from.

Now, if I want to delete a row in the "filename" table, which also deletes the records in the corresponding hypertable, the delete statement doesn't finish in hours or ever.

I tried creating an index on each "filename_id" column for every hypertable without much success.
Dropping the FK constraint on "filename_id" for all hypertables and deleting the records manually is not really an option, since the database runs in production and it also takes at least an hour drop, delete, and add them again.
Disabling triggers isn't possible, since hypertables do not support enabling or disabling triggers.

Is there any way to increase the performance?

The query plan of the delete statement on a small example database (0.1% data, ~250 hypertables with 150-200 columns each, 1-2 chunks per table) looks like this (removed some lines at "..." due to too many characters):

```"Delete on public.filename  (cost=0.28..2.50 rows=0 width=0) (actual time=0.175..0.176 rows=0 loops=1)"
"  Buffers: shared hit=5"
"  ->  Index Scan using filename_id_idx on public.filename  (cost=0.28..2.50 rows=1 width=6) (actual time=0.012..0.014 rows=1 loops=1)"
"        Output: ctid"
"        Index Cond: (filename.filename_id = 24666)"
"        Buffers: shared hit=3"
"Planning:"
"  Buffers: shared hit=10"
"Planning Time: 0.250 ms"
"Trigger RI_ConstraintTrigger_a_58218604 for constraint fk_filename: time=5.134 calls=1"
"Trigger RI_ConstraintTrigger_a_58218616 for constraint 1315_11243_fk_filename: time=7.619 calls=1"
"Trigger RI_ConstraintTrigger_a_58218642 for constraint 1316_11247_fk_filename: time=4.514 calls=1"
"Trigger RI_ConstraintTrigger_a_58218668 for constraint 1317_11251_fk_filename: time=5.351 calls=1"
"Trigger RI_ConstraintTrigger_a_58218708 for constraint fk_filename: time=3.758 calls=1"
"Trigger RI_ConstraintTrigger_a_58218720 for constraint 1318_11255_fk_filename: time=5.557 calls=1"
"Trigger RI_ConstraintTrigger_a_58218746 for constraint 1319_11259_fk_filename: time=4.424 calls=1"
"Trigger RI_ConstraintTrigger_a_58218772 for constraint 1320_11263_fk_filename: time=5.046 calls=1"
"Trigger RI_ConstraintTrigger_a_58218812 for constraint fk_filename: time=3.748 calls=1"
"Trigger RI_ConstraintTrigger_a_58218824 for constraint 1321_11267_fk_filename: time=6.224 calls=1"
"Trigger RI_ConstraintTrigger_a_58218864 for constraint fk_filename: time=0.122 calls=1"
"Trigger RI_ConstraintTrigger_a_58218876 for constraint 1322_11271_fk_filename: time=3.734 calls=1"
"Trigger RI_ConstraintTrigger_a_58218927 for constraint fk_filename: time=0.131 calls=1"
"Trigger RI_ConstraintTrigger_a_58218939 for constraint 1323_11275_fk_filename: time=0.392 calls=1"
"Trigger RI_ConstraintTrigger_a_58218979 for constraint fk_filename: time=0.104 calls=1"
"Trigger RI_ConstraintTrigger_a_58218991 for constraint 1324_11279_fk_filename: time=0.443 calls=1"
"Trigger RI_ConstraintTrigger_a_58219063 for constraint fk_filename: time=3.666 calls=1"
"Trigger RI_ConstraintTrigger_a_58219075 for constraint 1325_11283_fk_filename: time=5.813 calls=1"
"Trigger RI_ConstraintTrigger_a_58219115 for constraint fk_filename: time=3.958 calls=1"
"Trigger RI_ConstraintTrigger_a_58219127 for constraint 1326_11287_fk_filename: time=5.062 calls=1"
"Trigger RI_ConstraintTrigger_a_58219167 for constraint fk_filename: time=3.516 calls=1"
"Trigger RI_ConstraintTrigger_a_58219179 for constraint 1327_11291_fk_filename: time=7.007 calls=1"
"Trigger RI_ConstraintTrigger_a_58219219 for constraint fk_filename: time=3.806 calls=1"
"Trigger RI_ConstraintTrigger_a_58219231 for constraint 1328_11295_fk_filename: time=5.275 calls=1"
"Trigger RI_ConstraintTrigger_a_58219282 for constraint fk_filename: time=3.705 calls=1"
"Trigger RI_ConstraintTrigger_a_58219294 for constraint 1329_11299_fk_filename: time=6.859 calls=1"
"Trigger RI_ConstraintTrigger_a_58219334 for constraint fk_filename: time=3.579 calls=1"
"Trigger RI_ConstraintTrigger_a_58219346 for constraint 1330_11303_fk_filename: time=6.918 calls=1"
"Trigger RI_ConstraintTrigger_a_58219386 for constraint fk_filename: time=4.461 calls=1"
"Trigger RI_ConstraintTrigger_a_58219398 for constraint 1331_11307_fk_filename: time=6.496 calls=1"
"Trigger RI_ConstraintTrigger_a_58219438 for constraint fk_filename: time=3.815 calls=1"
"Trigger RI_ConstraintTrigger_a_58219450 for constraint 1332_11311_fk_filename: time=6.192 calls=1"
"Trigger RI_ConstraintTrigger_a_58219490 for constraint fk_filename: time=3.541 calls=1"
"Trigger RI_ConstraintTrigger_a_58219502 for constraint 1333_11315_fk_filename: time=5.046 calls=1"
"Trigger RI_ConstraintTrigger_a_58219542 for constraint fk_filename: time=3.510 calls=1"
"Trigger RI_ConstraintTrigger_a_58219554 for constraint 1334_11319_fk_filename: time=6.998 calls=1"
"Trigger RI_ConstraintTrigger_a_58219608 for constraint fk_filename: time=3.767 calls=1"
"Trigger RI_ConstraintTrigger_a_58219621 for constraint 1335_11323_fk_filename: time=5.484 calls=1"
"Trigger RI_ConstraintTrigger_a_58219661 for constraint fk_filename: time=4.211 calls=1"
"Trigger RI_ConstraintTrigger_a_58219673 for constraint 1336_11327_fk_filename: time=6.843 calls=1"
"Trigger RI_ConstraintTrigger_a_58219713 for constraint fk_filename: time=3.529 calls=1"
"Trigger RI_ConstraintTrigger_a_58219725 for constraint 1337_11331_fk_filename: time=7.456 calls=1"
"Trigger RI_ConstraintTrigger_a_58219765 for constraint fk_filename: time=3.666 calls=1"
"Trigger RI_ConstraintTrigger_a_58219777 for constraint 1338_11335_fk_filename: time=6.138 calls=1"
"Trigger RI_ConstraintTrigger_a_58219817 for constraint fk_filename: time=3.763 calls=1"
"Trigger RI_ConstraintTrigger_a_58219829 for constraint 1339_11339_fk_filename: time=5.874 calls=1"
"Trigger RI_ConstraintTrigger_a_58219869 for constraint fk_filename: time=3.593 calls=1"
"Trigger RI_ConstraintTrigger_a_58219881 for constraint 1340_11343_fk_filename: time=5.142 calls=1"
"Trigger RI_ConstraintTrigger_a_58219921 for constraint fk_filename: time=4.285 calls=1"
"Trigger RI_ConstraintTrigger_a_58219933 for constraint 1341_11347_fk_filename: time=6.046 calls=1"
"Trigger RI_ConstraintTrigger_a_58219973 for constraint fk_filename: time=3.840 calls=1"
"Trigger RI_ConstraintTrigger_a_58219985 for constraint 1342_11351_fk_filename: time=5.448 calls=1"
"Trigger RI_ConstraintTrigger_a_58220038 for constraint fk_filename: time=4.212 calls=1"
"Trigger RI_ConstraintTrigger_a_58220050 for constraint 1343_11355_fk_filename: time=5.989 calls=1"
"Trigger RI_ConstraintTrigger_a_58220090 for constraint fk_filename: time=3.915 calls=1"
"Trigger RI_ConstraintTrigger_a_58220102 for constraint 1344_11359_fk_filename: time=6.870 calls=1"
"Trigger RI_ConstraintTrigger_a_58220142 for constraint fk_filename: time=3.781 calls=1"
"Trigger RI_ConstraintTrigger_a_58220154 for constraint 1345_11363_fk_filename: time=6.303 calls=1"
"Trigger RI_ConstraintTrigger_a_58220194 for constraint fk_filename: time=3.932 calls=1"
"Trigger RI_ConstraintTrigger_a_58220206 for constraint 1346_11367_fk_filename: time=6.904 calls=1"
"Trigger RI_ConstraintTrigger_a_58220246 for constraint fk_filename: time=3.310 calls=1"
"Trigger RI_ConstraintTrigger_a_58220258 for constraint 1347_11371_fk_filename: time=6.708 calls=1"
"Trigger RI_ConstraintTrigger_a_58220308 for constraint fk_filename: time=3.699 calls=1"
"Trigger RI_ConstraintTrigger_a_58220320 for constraint 1348_11375_fk_filename: time=5.620 calls=1"
"Trigger RI_ConstraintTrigger_a_58220360 for constraint fk_filename: time=3.481 calls=1"
"Trigger RI_ConstraintTrigger_a_58220372 for constraint 1349_11379_fk_filename: time=5.363 calls=1"
"Trigger RI_ConstraintTrigger_a_58220412 for constraint fk_filename: time=3.434 calls=1"
"Trigger RI_ConstraintTrigger_a_58220424 for constraint 1350_11383_fk_filename: time=4.801 calls=1"
"Trigger RI_ConstraintTrigger_a_58220474 for constraint fk_filename: time=3.632 calls=1"
"Trigger RI_ConstraintTrigger_a_58220486 for constraint 1351_11387_fk_filename: time=6.667 calls=1"
"Trigger RI_ConstraintTrigger_a_58220526 for constraint fk_filename: time=3.664 calls=1"
"Trigger RI_ConstraintTrigger_a_58220538 for constraint 1352_11391_fk_filename: time=7.010 calls=1"
"Trigger RI_ConstraintTrigger_a_58220578 for constraint fk_filename: time=4.005 calls=1"
"Trigger RI_ConstraintTrigger_a_58220590 for constraint 1353_11395_fk_filename: time=4.918 calls=1"
"Trigger RI_ConstraintTrigger_a_58220630 for constraint fk_filename: time=3.482 calls=1"
"Trigger RI_ConstraintTrigger_a_58220642 for constraint 1354_11399_fk_filename: time=5.270 calls=1"
"Trigger RI_ConstraintTrigger_a_58220695 for constraint fk_filename: time=3.849 calls=1"
"Trigger RI_ConstraintTrigger_a_58220707 for constraint 1355_11403_fk_filename: time=5.400 calls=1"
"Trigger RI_ConstraintTrigger_a_58220748 for constraint fk_filename: time=3.474 calls=1"
"Trigger RI_ConstraintTrigger_a_58220760 for constraint 1356_11407_fk_filename: time=7.003 calls=1"
"Trigger RI_ConstraintTrigger_a_58220800 for constraint fk_filename: time=3.905 calls=1"
"Trigger RI_ConstraintTrigger_a_58220812 for constraint 1357_11411_fk_filename: time=6.710 calls=1"
"Trigger RI_ConstraintTrigger_a_58220852 for constraint fk_filename: time=3.990 calls=1"
"Trigger RI_ConstraintTrigger_a_58220864 for constraint 1358_11415_fk_filename: time=6.525 calls=1"
"Trigger RI_ConstraintTrigger_a_58220904 for constraint fk_filename: time=3.735 calls=1"
"Trigger RI_ConstraintTrigger_a_58220916 for constraint 1359_11419_fk_filename: time=5.808 calls=1"
"Trigger RI_ConstraintTrigger_a_58220967 for constraint fk_filename: time=3.842 calls=1"
"Trigger RI_ConstraintTrigger_a_58220979 for constraint 1360_11423_fk_filename: time=6.655 calls=1"
"Trigger RI_ConstraintTrigger_a_58221022 for constraint fk_filename: time=4.667 calls=1"
"Trigger RI_ConstraintTrigger_a_58221034 for constraint 1361_11427_fk_filename: time=5.479 calls=1"
"Trigger RI_ConstraintTrigger_a_58221074 for constraint fk_filename: time=3.547 calls=1"
"Trigger RI_ConstraintTrigger_a_58221086 for constraint 1362_11431_fk_filename: time=6.817 calls=1"
"Trigger RI_ConstraintTrigger_a_58221126 for constraint fk_filename: time=3.961 calls=1"
"Trigger RI_ConstraintTrigger_a_58221138 for constraint 1363_11435_fk_filename: time=6.503 calls=1"
"Trigger RI_ConstraintTrigger_a_58221178 for constraint fk_filename: time=3.757 calls=1"
"Trigger RI_ConstraintTrigger_a_58221190 for constraint 1364_11439_fk_filename: time=7.066 calls=1"
"Trigger RI_ConstraintTrigger_a_58221237 for constraint fk_filename: time=3.910 calls=1"
"Trigger RI_ConstraintTrigger_a_58221249 for constraint 1365_11443_fk_filename: time=6.597 calls=1"
"Trigger RI_ConstraintTrigger_a_58221291 for constraint fk_filename: time=4.284 calls=1"
"Trigger RI_ConstraintTrigger_a_58221303 for constraint 1366_11447_fk_filename: time=7.540 calls=1"
"Trigger RI_ConstraintTrigger_a_58221343 for constraint fk_filename: time=3.479 calls=1"
"Trigger RI_ConstraintTrigger_a_58221355 for constraint 1367_11451_fk_filename: time=5.321 calls=1"
"Trigger RI_ConstraintTrigger_a_58221395 for constraint fk_filename: time=4.172 calls=1"
"Trigger RI_ConstraintTrigger_a_58221407 for constraint 1368_11455_fk_filename: time=5.331 calls=1"
"Trigger RI_ConstraintTrigger_a_58221447 for constraint fk_filename: time=3.464 calls=1"
"Trigger RI_ConstraintTrigger_a_58221459 for constraint 1369_11459_fk_filename: time=5.503 calls=1"
"Trigger RI_ConstraintTrigger_a_58221499 for constraint fk_filename: time=3.790 calls=1"
"Trigger RI_ConstraintTrigger_a_58221511 for constraint 1370_11463_fk_filename: time=5.402 calls=1"
"Trigger RI_ConstraintTrigger_a_58221551 for constraint fk_filename: time=3.582 calls=1"
"Trigger RI_ConstraintTrigger_a_58221563 for constraint 1371_11467_fk_filename: time=7.325 calls=1"
"Trigger RI_ConstraintTrigger_a_58221603 for constraint fk_filename: time=3.486 calls=1"
"Trigger RI_ConstraintTrigger_a_58221621 for constraint 1372_11471_fk_filename: time=6.640 calls=1"
"Trigger RI_ConstraintTrigger_a_58221665 for constraint fk_filename: time=5.134 calls=1"
"Trigger RI_ConstraintTrigger_a_58221677 for constraint 1373_11475_fk_filename: time=4.919 calls=1"
"Trigger RI_ConstraintTrigger_a_58221717 for constraint fk_filename: time=3.374 calls=1"
"Trigger RI_ConstraintTrigger_a_58221729 for constraint 1374_11479_fk_filename: time=5.891 calls=1"
"Trigger RI_ConstraintTrigger_a_58221769 for constraint fk_filename: time=3.690 calls=1"
"Trigger RI_ConstraintTrigger_a_58221781 for constraint 1375_11483_fk_filename: time=6.095 calls=1"
"Trigger RI_ConstraintTrigger_a_58221834 for constraint fk_filename: time=4.093 calls=1"
"Trigger RI_ConstraintTrigger_a_58221846 for constraint 1376_11487_fk_filename: time=6.956 calls=1"
"Trigger RI_ConstraintTrigger_a_58221886 for constraint fk_filename: time=3.675 calls=1"
"Trigger RI_ConstraintTrigger_a_58221898 for constraint 1377_11491_fk_filename: time=42.609 calls=1"
"Trigger RI_ConstraintTrigger_a_58221938 for constraint fk_filename: time=24.221 calls=1"
"Trigger RI_ConstraintTrigger_a_58221950 for constraint 1378_11495_fk_filename: time=7.879 calls=1"
"Trigger RI_ConstraintTrigger_a_58221990 for constraint fk_filename: time=6.555 calls=1"
"Trigger RI_ConstraintTrigger_a_58222002 for constraint 1379_11499_fk_filename: time=7.765 calls=1"
"Trigger RI_ConstraintTrigger_a_58222042 for constraint fk_filename: time=5.678 calls=1"
"Trigger RI_ConstraintTrigger_a_58222054 for constraint 1380_11503_fk_filename: time=8.225 calls=1"
"Trigger RI_ConstraintTrigger_a_58222105 for constraint fk_filename: time=7.696 calls=1"
"Trigger RI_ConstraintTrigger_a_58222118 for constraint 1381_11507_fk_filename: time=9.930 calls=1"
"Trigger RI_ConstraintTrigger_a_58222158 for constraint fk_filename: time=5.197 calls=1"
"Trigger RI_ConstraintTrigger_a_58222170 for constraint 1382_11511_fk_filename: time=8.397 calls=1"
"Trigger RI_ConstraintTrigger_a_58222210 for constraint fk_filename: time=4.494 calls=1"
"Trigger RI_ConstraintTrigger_a_58222222 for constraint 1383_11515_fk_filename: time=8.280 calls=1"
"Trigger RI_ConstraintTrigger_a_58222262 for constraint fk_filename: time=4.100 calls=1"
"Trigger RI_ConstraintTrigger_a_58222274 for constraint 1384_11519_fk_filename: time=6.736 calls=1"
"Trigger RI_ConstraintTrigger_a_58222314 for constraint fk_filename: time=3.823 calls=1"
"Trigger RI_ConstraintTrigger_a_58222326 for constraint 1385_11523_fk_filename: time=6.443 calls=1"
"Trigger RI_ConstraintTrigger_a_58222366 for constraint fk_filename: time=4.324 calls=1"
"Trigger RI_ConstraintTrigger_a_58222378 for constraint 1386_11527_fk_filename: time=7.069 calls=1"
"Trigger RI_ConstraintTrigger_a_58222426 for constraint fk_filename: time=3.873 calls=1"
"Trigger RI_ConstraintTrigger_a_58222441 for constraint 1387_11531_fk_filename: time=5.298 calls=1"
"Trigger RI_ConstraintTrigger_a_58222495 for constraint fk_filename: time=3.607 calls=1"
"Trigger RI_ConstraintTrigger_a_58222507 for constraint 1388_11535_fk_filename: time=5.445 calls=1"
"Trigger RI_ConstraintTrigger_a_58222547 for constraint fk_filename: time=3.445 calls=1"
"Trigger RI_ConstraintTrigger_a_58222559 for constraint 1389_11539_fk_filename: time=6.043 calls=1"
"Trigger RI_ConstraintTrigger_a_58222599 for constraint fk_filename: time=3.774 calls=1"
"Trigger RI_ConstraintTrigger_a_58222611 for constraint 1390_11543_fk_filename: time=6.550 calls=1"
"Trigger RI_ConstraintTrigger_a_58222651 for constraint fk_filename: time=3.030 calls=1"
"Trigger RI_ConstraintTrigger_a_58222663 for constraint 1391_11547_fk_filename: time=6.151 calls=1"
"Trigger RI_ConstraintTrigger_a_58222703 for constraint fk_filename: time=2.958 calls=1"
"Trigger RI_ConstraintTrigger_a_58222715 for constraint 1392_11551_fk_filename: time=5.232 calls=1"
"Trigger RI_ConstraintTrigger_a_58222755 for constraint fk_filename: time=2.855 calls=1"
"Trigger RI_ConstraintTrigger_a_58222767 for constraint 1393_11555_fk_filename: time=6.605 calls=1"
"Trigger RI_ConstraintTrigger_a_58222807 for constraint fk_filename: time=3.003 calls=1"
"Trigger RI_ConstraintTrigger_a_58222820 for constraint 1394_11559_fk_filename: time=5.206 calls=1"
"Trigger RI_ConstraintTrigger_a_58222870 for constraint fk_filename: time=3.330 calls=1"
"Trigger RI_ConstraintTrigger_a_58222882 for constraint 1395_11563_fk_filename: time=5.927 calls=1"
"Trigger RI_ConstraintTrigger_a_58222922 for constraint fk_filename: time=2.889 calls=1"
"Trigger RI_ConstraintTrigger_a_58222934 for constraint 1396_11567_fk_filename: time=4.461 calls=1"
"Trigger RI_ConstraintTrigger_a_58222974 for constraint fk_filename: time=3.121 calls=1"
"Trigger RI_ConstraintTrigger_a_58222986 for constraint 1397_11571_fk_filename: time=6.212 calls=1"
"Trigger RI_ConstraintTrigger_a_58223026 for constraint fk_filename: time=3.290 calls=1"
"Trigger RI_ConstraintTrigger_a_58223041 for constraint 1398_11575_fk_filename: time=4.182 calls=1"
"Trigger RI_ConstraintTrigger_a_58223082 for constraint fk_filename: time=3.112 calls=1"
"Trigger RI_ConstraintTrigger_a_58223094 for constraint 1399_11579_fk_filename: time=4.665 calls=1"
"Trigger RI_ConstraintTrigger_a_58223134 for constraint fk_filename: time=3.981 calls=1"
"Trigger RI_ConstraintTrigger_a_58223146 for constraint 1400_11583_fk_filename: time=4.189 calls=1"
"Trigger RI_ConstraintTrigger_a_58223186 for constraint fk_filename: time=3.079 calls=1"
"Trigger RI_ConstraintTrigger_a_58223198 for constraint 1401_11587_fk_filename: time=4.541 calls=1"
"Trigger RI_ConstraintTrigger_a_58223245 for constraint fk_filename: time=2.959 calls=1"
"Trigger RI_ConstraintTrigger_a_58223257 for constraint 1402_11591_fk_filename: time=4.356 calls=1"
"Trigger RI_ConstraintTrigger_a_58223283 for constraint 1403_11595_fk_filename: time=3.154 calls=1"
"Trigger RI_ConstraintTrigger_a_58223325 for constraint fk_filename: time=4.479 calls=1"
"Trigger RI_ConstraintTrigger_a_58223337 for constraint 1404_11599_fk_filename: time=3.324 calls=1"
"Trigger RI_ConstraintTrigger_a_58223377 for constraint fk_filename: time=4.157 calls=1"
"Trigger RI_ConstraintTrigger_a_58223389 for constraint 1405_11603_fk_filename: time=3.124 calls=1"
"Trigger RI_ConstraintTrigger_a_58223429 for constraint fk_filename: time=4.307 calls=1"
"Trigger RI_ConstraintTrigger_a_58223441 for constraint 1406_11607_fk_filename: time=3.558 calls=1"
"Trigger RI_ConstraintTrigger_a_58223492 for constraint fk_filename: time=5.441 calls=1"
"Trigger RI_ConstraintTrigger_a_58223504 for constraint 1407_11611_fk_filename: time=3.754 calls=1"
"Trigger RI_ConstraintTrigger_a_58223544 for constraint fk_filename: time=6.559 calls=1"
"Trigger RI_ConstraintTrigger_a_58223556 for constraint 1408_11615_fk_filename: time=4.170 calls=1"
"Trigger RI_ConstraintTrigger_a_58223597 for constraint fk_filename: time=4.274 calls=1"
"Trigger RI_ConstraintTrigger_a_58223609 for constraint 1409_11619_fk_filename: time=3.089 calls=1"
"Trigger RI_ConstraintTrigger_a_58223649 for constraint fk_filename: time=5.058 calls=1"
"Trigger RI_ConstraintTrigger_a_58223661 for constraint 1410_11623_fk_filename: time=3.503 calls=1"
"Trigger RI_ConstraintTrigger_a_58223701 for constraint fk_filename: time=5.118 calls=1"
"Trigger RI_ConstraintTrigger_a_58223713 for constraint 1411_11627_fk_filename: time=3.357 calls=1"
"Trigger RI_ConstraintTrigger_a_58223753 for constraint fk_filename: time=5.676 calls=1"
"Trigger RI_ConstraintTrigger_a_58223765 for constraint 1412_11631_fk_filename: time=3.256 calls=1"
"Trigger RI_ConstraintTrigger_a_58223816 for constraint fk_filename: time=4.124 calls=1"
"Trigger RI_ConstraintTrigger_a_58223828 for constraint 1413_11635_fk_filename: time=3.042 calls=1"
"Trigger RI_ConstraintTrigger_a_58223873 for constraint fk_filename: time=4.542 calls=1"
"Trigger RI_ConstraintTrigger_a_58223885 for constraint 1414_11639_fk_filename: time=3.285 calls=1"
"Trigger RI_ConstraintTrigger_a_58223925 for constraint fk_filename: time=5.209 calls=1"
"Trigger RI_ConstraintTrigger_a_58223937 for constraint 1415_11643_fk_filename: time=3.122 calls=1"
"Trigger RI_ConstraintTrigger_a_58223977 for constraint fk_filename: time=5.885 calls=1"
"Trigger RI_ConstraintTrigger_a_58223989 for constraint 1416_11647_fk_filename: time=3.509 calls=1"
"Trigger RI_ConstraintTrigger_a_58224029 for constraint fk_filename: time=4.560 calls=1"
"Trigger RI_ConstraintTrigger_a_58224041 for constraint 1417_11651_fk_filename: time=3.316 calls=1"
"Trigger RI_ConstraintTrigger_a_58224081 for constraint fk_filename: time=4.583 calls=1"
"Trigger RI_ConstraintTrigger_a_58224093 for constraint 1418_11655_fk_filename: time=3.329 calls=1"
"Trigger RI_ConstraintTrigger_a_58224133 for constraint fk_filename: time=4.157 calls=1"
"Trigger RI_ConstraintTrigger_a_58224149 for constraint 1419_11659_fk_filename: time=3.167 calls=1"
"Trigger RI_ConstraintTrigger_a_58224192 for constraint fk_filename: time=4.309 calls=1"
"Trigger RI_ConstraintTrigger_a_58224204 for constraint 1420_11663_fk_filename: time=3.371 calls=1"
"Trigger RI_ConstraintTrigger_a_58224247 for constraint fk_filename: time=5.212 calls=1"
"Trigger RI_ConstraintTrigger_a_58224259 for constraint 1421_11667_fk_filename: time=3.257 calls=1"
"Trigger RI_ConstraintTrigger_a_58224299 for constraint fk_filename: time=4.430 calls=1"
"Trigger RI_ConstraintTrigger_a_58224311 for constraint 1422_11671_fk_filename: time=3.589 calls=1"
"Trigger RI_ConstraintTrigger_a_58224351 for constraint fk_filename: time=5.288 calls=1"
"Trigger RI_ConstraintTrigger_a_58224363 for constraint 1423_11675_fk_filename: time=3.152 calls=1"
"Trigger RI_ConstraintTrigger_a_58224403 for constraint fk_filename: time=5.619 calls=1"
"Trigger RI_ConstraintTrigger_a_58224415 for constraint 1424_11679_fk_filename: time=3.796 calls=1"
"Trigger RI_ConstraintTrigger_a_58224460 for constraint fk_filename: time=5.503 calls=1"
"Trigger RI_ConstraintTrigger_a_58224472 for constraint 1425_11683_fk_filename: time=3.139 calls=1"
"Trigger RI_ConstraintTrigger_a_58224512 for constraint fk_filename: time=6.265 calls=1"
"Trigger RI_ConstraintTrigger_a_58224524 for constraint 1426_11687_fk_filename: time=3.292 calls=1"
"Trigger RI_ConstraintTrigger_a_58224564 for constraint fk_filename: time=4.223 calls=1"
"Trigger RI_ConstraintTrigger_a_58224576 for constraint 1427_11691_fk_filename: time=3.112 calls=1"
"Trigger RI_ConstraintTrigger_a_58224616 for constraint fk_filename: time=6.118 calls=1"
"Trigger RI_ConstraintTrigger_a_58224628 for constraint 1428_11695_fk_filename: time=3.361 calls=1"
"Trigger RI_ConstraintTrigger_a_58224668 for constraint fk_filename: time=5.639 calls=1"
"Trigger RI_ConstraintTrigger_a_58224680 for constraint 1429_11699_fk_filename: time=3.106 calls=1"
"Trigger RI_ConstraintTrigger_a_58224720 for constraint fk_filename: time=5.693 calls=1"
"Trigger RI_ConstraintTrigger_a_58224732 for constraint 1430_11703_fk_filename: time=3.172 calls=1"
"Trigger RI_ConstraintTrigger_a_58224788 for constraint fk_filename: time=4.919 calls=1"
"Trigger RI_ConstraintTrigger_a_58224805 for constraint 1431_11707_fk_filename: time=3.101 calls=1"
"Trigger RI_ConstraintTrigger_a_58224845 for constraint fk_filename: time=5.822 calls=1"
"Trigger RI_ConstraintTrigger_a_58224857 for constraint 1432_11711_fk_filename: time=3.769 calls=1"
"Trigger RI_ConstraintTrigger_a_58224897 for constraint fk_filename: time=4.935 calls=1"
"Trigger RI_ConstraintTrigger_a_58224909 for constraint 1433_11715_fk_filename: time=3.604 calls=1"
"Trigger RI_ConstraintTrigger_a_58224949 for constraint fk_filename: time=5.002 calls=1"
"Trigger RI_ConstraintTrigger_a_58224961 for constraint 1434_11719_fk_filename: time=3.447 calls=1"
"Trigger RI_ConstraintTrigger_a_58225001 for constraint fk_filename: time=4.479 calls=1"
"Trigger RI_ConstraintTrigger_a_58225013 for constraint 1435_11723_fk_filename: time=4.274 calls=1"
"Trigger RI_ConstraintTrigger_a_58225053 for constraint fk_filename: time=8.053 calls=1"
"Trigger RI_ConstraintTrigger_a_58225065 for constraint 1436_11727_fk_filename: time=9.265 calls=1"
"Trigger RI_ConstraintTrigger_a_58225105 for constraint fk_filename: time=3.783 calls=1"
"Trigger RI_ConstraintTrigger_a_58225117 for constraint 1437_11731_fk_filename: time=5.919 calls=1"
"Trigger RI_ConstraintTrigger_a_58225170 for constraint fk_filename: time=3.343 calls=1"
"Trigger RI_ConstraintTrigger_a_58225182 for constraint 1438_11735_fk_filename: time=5.461 calls=1"
"Trigger RI_ConstraintTrigger_a_58225222 for constraint fk_filename: time=3.203 calls=1"
"Trigger RI_ConstraintTrigger_a_58225234 for constraint 1439_11739_fk_filename: time=3.177 calls=1"
"Trigger RI_ConstraintTrigger_a_58225274 for constraint fk_filename: time=2.994 calls=1"
"Trigger RI_ConstraintTrigger_a_58225286 for constraint 1440_11743_fk_filename: time=5.852 calls=1"
"Trigger RI_ConstraintTrigger_a_58225342 for constraint fk_filename: time=3.455 calls=1"
"Trigger RI_ConstraintTrigger_a_58225354 for constraint 1441_11747_fk_filename: time=4.543 calls=1"
"Trigger RI_ConstraintTrigger_a_58225394 for constraint fk_filename: time=4.346 calls=1"
"Trigger RI_ConstraintTrigger_a_58225406 for constraint 1442_11751_fk_filename: time=3.716 calls=1"
"Trigger RI_ConstraintTrigger_a_58225446 for constraint fk_filename: time=5.577 calls=1"
"Trigger RI_ConstraintTrigger_a_58225458 for constraint 1443_11755_fk_filename: time=3.179 calls=1"
"Trigger RI_ConstraintTrigger_a_58225498 for constraint fk_filename: time=5.563 calls=1"
"Trigger RI_ConstraintTrigger_a_58225510 for constraint 1444_11759_fk_filename: time=3.696 calls=1"
"Trigger RI_ConstraintTrigger_a_58225550 for constraint fk_filename: time=4.453 calls=1"
"Trigger RI_ConstraintTrigger_a_58225562 for constraint 1445_11763_fk_filename: time=3.684 calls=1"
"Trigger RI_ConstraintTrigger_a_58225602 for constraint fk_filename: time=4.439 calls=1"
"Trigger RI_ConstraintTrigger_a_58225614 for constraint 1446_11767_fk_filename: time=5.292 calls=1"
"Trigger RI_ConstraintTrigger_a_58225654 for constraint fk_filename: time=4.199 calls=1"
"Trigger RI_ConstraintTrigger_a_58225666 for constraint 1447_11771_fk_filename: time=3.172 calls=1"
"Trigger RI_ConstraintTrigger_a_58225716 for constraint fk_filename: time=3.869 calls=1"
"Trigger RI_ConstraintTrigger_a_58225728 for constraint 1448_11775_fk_filename: time=3.511 calls=1"
"Trigger RI_ConstraintTrigger_a_58225768 for constraint fk_filename: time=4.242 calls=1"
"Trigger RI_ConstraintTrigger_a_58225780 for constraint 1449_11779_fk_filename: time=3.312 calls=1"
"Trigger RI_ConstraintTrigger_a_58225820 for constraint fk_filename: time=3.941 calls=1"
"Trigger RI_ConstraintTrigger_a_58225832 for constraint 1450_11783_fk_filename: time=3.266 calls=1"
"Trigger RI_ConstraintTrigger_a_58225879 for constraint fk_filename: time=5.646 calls=1"
"Trigger RI_ConstraintTrigger_a_58225891 for constraint 1451_11787_fk_filename: time=3.369 calls=1"
"Trigger RI_ConstraintTrigger_a_58225931 for constraint fk_filename: time=5.267 calls=1"
"Trigger RI_ConstraintTrigger_a_58225948 for constraint 1452_11791_fk_filename: time=3.817 calls=1"
"Trigger RI_ConstraintTrigger_a_58225988 for constraint fk_filename: time=4.204 calls=1"
"Trigger RI_ConstraintTrigger_a_58226000 for constraint 1453_11795_fk_filename: time=3.111 calls=1"
"Trigger RI_ConstraintTrigger_a_58226040 for constraint fk_filename: time=3.945 calls=1"
"Trigger RI_ConstraintTrigger_a_58226052 for constraint 1454_11799_fk_filename: time=3.180 calls=1"
"Trigger RI_ConstraintTrigger_a_58226092 for constraint fk_filename: time=4.331 calls=1"
"Trigger RI_ConstraintTrigger_a_58226104 for constraint 1455_11803_fk_filename: time=3.110 calls=1"
"Trigger RI_ConstraintTrigger_a_58226144 for constraint fk_filename: time=4.097 calls=1"
"Trigger RI_ConstraintTrigger_a_58226165 for constraint 1456_11807_fk_filename: time=3.308 calls=1"
"Trigger RI_ConstraintTrigger_a_58226206 for constraint fk_filename: time=5.616 calls=1"
"Trigger RI_ConstraintTrigger_a_58226218 for constraint 1457_11811_fk_filename: time=3.323 calls=1"
"Trigger RI_ConstraintTrigger_a_58226270 for constraint fk_filename: time=5.329 calls=1"
...
"Execution Time: 2550.275 ms"
```

Body:
I have around 1500 hypertables with 150-200 columns and millions of rows each in a timescale database (~ 1TB size, compression disabled, currently ~20 chunks for each hypertable, v2.5). Basically, all of those hypertables contain sensor values from machines - one hypertable for each machine. Data gets read from incoming csv-files and is stored in the corresponding hypertable which is determined by the csv-filename. All the hypertables have a column "filename_id" (foreign key, ON DELETE CASCADE) which reference to an indexed ID column of a normal table "filename". This is necessary to keep track of the csv-files that have been read and stored into the database and also keep track of the filename from which each data record in a hypertable came from.

Now, if I want to delete a row in the "filename" table, which also deletes the records in the corresponding hypertable, the delete statement doesn't finish in hours or ever.

I tried creating an index on each "filename_id" column for every hypertable without much success.
Dropping the FK constraint on "filename_id" for all hypertables and deleting the records manually is not really an option, since the database runs in production and it also takes at least an hour drop, delete, and add them again.
Disabling triggers isn't possible, since hypertables do not support enabling or disabling triggers.

Is there any way to increase the performance?

The query plan of the delete statement on a small example database (0.1% data, ~250 hypertables with 150-200 columns each, 1-2 chunks per table) looks like this (removed some lines at "..." due to too many characters):

"Delete on public.filename  (cost=0.28..2.50 rows=0 width=0) (actual time=0.175..0.176 rows=0 loops=1)"
"  Buffers: shared hit=5"
"  ->  Index Scan using filename_id_idx on public.filename  (cost=0.28..2.50 rows=1 width=6) (actual time=0.012..0.014 rows=1 loops=1)"
"        Output: ctid"
"        Index Cond: (filename.filename_id = 24666)"
"        Buffers: shared hit=3"
"Planning:"
"  Buffers: shared hit=10"
"Planning Time: 0.250 ms"
"Trigger RI_ConstraintTrigger_a_58218604 for constraint fk_filename: time=5.134 calls=1"
"Trigger RI_ConstraintTrigger_a_58218616 for constraint 1315_11243_fk_filename: time=7.619 calls=1"
"Trigger RI_ConstraintTrigger_a_58218642 for constraint 1316_11247_fk_filename: time=4.514 calls=1"
"Trigger RI_ConstraintTrigger_a_58218668 for constraint 1317_11251_fk_filename: time=5.351 calls=1"
"Trigger RI_ConstraintTrigger_a_58218708 for constraint fk_filename: time=3.758 calls=1"
"Trigger RI_ConstraintTrigger_a_58218720 for constraint 1318_11255_fk_filename: time=5.557 calls=1"
"Trigger RI_ConstraintTrigger_a_58218746 for constraint 1319_11259_fk_filename: time=4.424 calls=1"
"Trigger RI_ConstraintTrigger_a_58218772 for constraint 1320_11263_fk_filename: time=5.046 calls=1"
"Trigger RI_ConstraintTrigger_a_58218812 for constraint fk_filename: time=3.748 calls=1"
"Trigger RI_ConstraintTrigger_a_58218824 for constraint 1321_11267_fk_filename: time=6.224 calls=1"
"Trigger RI_ConstraintTrigger_a_58218864 for constraint fk_filename: time=0.122 calls=1"
"Trigger RI_ConstraintTrigger_a_58218876 for constraint 1322_11271_fk_filename: time=3.734 calls=1"
"Trigger RI_ConstraintTrigger_a_58218927 for constraint fk_filename: time=0.131 calls=1"
"Trigger RI_ConstraintTrigger_a_58218939 for constraint 1323_11275_fk_filename: time=0.392 calls=1"
"Trigger RI_ConstraintTrigger_a_58218979 for constraint fk_filename: time=0.104 calls=1"
"Trigger RI_ConstraintTrigger_a_58218991 for constraint 1324_11279_fk_filename: time=0.443 calls=1"
"Trigger RI_ConstraintTrigger_a_58219063 for constraint fk_filename: time=3.666 calls=1"
"Trigger RI_ConstraintTrigger_a_58219075 for constraint 1325_11283_fk_filename: time=5.813 calls=1"
"Trigger RI_ConstraintTrigger_a_58219115 for constraint fk_filename: time=3.958 calls=1"
"Trigger RI_ConstraintTrigger_a_58219127 for constraint 1326_11287_fk_filename: time=5.062 calls=1"
"Trigger RI_ConstraintTrigger_a_58219167 for constraint fk_filename: time=3.516 calls=1"
"Trigger RI_ConstraintTrigger_a_58219179 for constraint 1327_11291_fk_filename: time=7.007 calls=1"
"Trigger RI_ConstraintTrigger_a_58219219 for constraint fk_filename: time=3.806 calls=1"
"Trigger RI_ConstraintTrigger_a_58219231 for constraint 1328_11295_fk_filename: time=5.275 calls=1"
"Trigger RI_ConstraintTrigger_a_58219282 for constraint fk_filename: time=3.705 calls=1"
"Trigger RI_ConstraintTrigger_a_58219294 for constraint 1329_11299_fk_filename: time=6.859 calls=1"
"Trigger RI_ConstraintTrigger_a_58219334 for constraint fk_filename: time=3.579 calls=1"
"Trigger RI_ConstraintTrigger_a_58219346 for constraint 1330_11303_fk_filename: time=6.918 calls=1"
"Trigger RI_ConstraintTrigger_a_58219386 for constraint fk_filename: time=4.461 calls=1"
"Trigger RI_ConstraintTrigger_a_58219398 for constraint 1331_11307_fk_filename: time=6.496 calls=1"
"Trigger RI_ConstraintTrigger_a_58219438 for constraint fk_filename: time=3.815 calls=1"
"Trigger RI_ConstraintTrigger_a_58219450 for constraint 1332_11311_fk_filename: time=6.192 calls=1"
"Trigger RI_ConstraintTrigger_a_58219490 for constraint fk_filename: time=3.541 calls=1"
"Trigger RI_ConstraintTrigger_a_58219502 for constraint 1333_11315_fk_filename: time=5.046 calls=1"
"Trigger RI_ConstraintTrigger_a_58219542 for constraint fk_filename: time=3.510 calls=1"
"Trigger RI_ConstraintTrigger_a_58219554 for constraint 1334_11319_fk_filename: time=6.998 calls=1"
"Trigger RI_ConstraintTrigger_a_58219608 for constraint fk_filename: time=3.767 calls=1"
"Trigger RI_ConstraintTrigger_a_58219621 for constraint 1335_11323_fk_filename: time=5.484 calls=1"
"Trigger RI_ConstraintTrigger_a_58219661 for constraint fk_filename: time=4.211 calls=1"
"Trigger RI_ConstraintTrigger_a_58219673 for constraint 1336_11327_fk_filename: time=6.843 calls=1"
"Trigger RI_ConstraintTrigger_a_58219713 for constraint fk_filename: time=3.529 calls=1"
"Trigger RI_ConstraintTrigger_a_58219725 for constraint 1337_11331_fk_filename: time=7.456 calls=1"
"Trigger RI_ConstraintTrigger_a_58219765 for constraint fk_filename: time=3.666 calls=1"
"Trigger RI_ConstraintTrigger_a_58219777 for constraint 1338_11335_fk_filename: time=6.138 calls=1"
"Trigger RI_ConstraintTrigger_a_58219817 for constraint fk_filename: time=3.763 calls=1"
"Trigger RI_ConstraintTrigger_a_58219829 for constraint 1339_11339_fk_filename: time=5.874 calls=1"
"Trigger RI_ConstraintTrigger_a_58219869 for constraint fk_filename: time=3.593 calls=1"
"Trigger RI_ConstraintTrigger_a_58219881 for constraint 1340_11343_fk_filename: time=5.142 calls=1"
"Trigger RI_ConstraintTrigger_a_58219921 for constraint fk_filename: time=4.285 calls=1"
"Trigger RI_ConstraintTrigger_a_58219933 for constraint 1341_11347_fk_filename: time=6.046 calls=1"
"Trigger RI_ConstraintTrigger_a_58219973 for constraint fk_filename: time=3.840 calls=1"
"Trigger RI_ConstraintTrigger_a_58219985 for constraint 1342_11351_fk_filename: time=5.448 calls=1"
"Trigger RI_ConstraintTrigger_a_58220038 for constraint fk_filename: time=4.212 calls=1"
"Trigger RI_ConstraintTrigger_a_58220050 for constraint 1343_11355_fk_filename: time=5.989 calls=1"
"Trigger RI_ConstraintTrigger_a_58220090 for constraint fk_filename: time=3.915 calls=1"
"Trigger RI_ConstraintTrigger_a_58220102 for constraint 1344_11359_fk_filename: time=6.870 calls=1"
"Trigger RI_ConstraintTrigger_a_58220142 for constraint fk_filename: time=3.781 calls=1"
"Trigger RI_ConstraintTrigger_a_58220154 for constraint 1345_11363_fk_filename: time=6.303 calls=1"
"Trigger RI_ConstraintTrigger_a_58220194 for constraint fk_filename: time=3.932 calls=1"
"Trigger RI_ConstraintTrigger_a_58220206 for constraint 1346_11367_fk_filename: time=6.904 calls=1"
"Trigger RI_ConstraintTrigger_a_58220246 for constraint fk_filename: time=3.310 calls=1"
"Trigger RI_ConstraintTrigger_a_58220258 for constraint 1347_11371_fk_filename: time=6.708 calls=1"
"Trigger RI_ConstraintTrigger_a_58220308 for constraint fk_filename: time=3.699 calls=1"
"Trigger RI_ConstraintTrigger_a_58220320 for constraint 1348_11375_fk_filename: time=5.620 calls=1"
"Trigger RI_ConstraintTrigger_a_58220360 for constraint fk_filename: time=3.481 calls=1"
"Trigger RI_ConstraintTrigger_a_58220372 for constraint 1349_11379_fk_filename: time=5.363 calls=1"
"Trigger RI_ConstraintTrigger_a_58220412 for constraint fk_filename: time=3.434 calls=1"
"Trigger RI_ConstraintTrigger_a_58220424 for constraint 1350_11383_fk_filename: time=4.801 calls=1"
"Trigger RI_ConstraintTrigger_a_58220474 for constraint fk_filename: time=3.632 calls=1"
"Trigger RI_ConstraintTrigger_a_58220486 for constraint 1351_11387_fk_filename: time=6.667 calls=1"
"Trigger RI_ConstraintTrigger_a_58220526 for constraint fk_filename: time=3.664 calls=1"
"Trigger RI_ConstraintTrigger_a_58220538 for constraint 1352_11391_fk_filename: time=7.010 calls=1"
"Trigger RI_ConstraintTrigger_a_58220578 for constraint fk_filename: time=4.005 calls=1"
"Trigger RI_ConstraintTrigger_a_58220590 for constraint 1353_11395_fk_filename: time=4.918 calls=1"
"Trigger RI_ConstraintTrigger_a_58220630 for constraint fk_filename: time=3.482 calls=1"
"Trigger RI_ConstraintTrigger_a_58220642 for constraint 1354_11399_fk_filename: time=5.270 calls=1"
"Trigger RI_ConstraintTrigger_a_58220695 for constraint fk_filename: time=3.849 calls=1"
"Trigger RI_ConstraintTrigger_a_58220707 for constraint 1355_11403_fk_filename: time=5.400 calls=1"
"Trigger RI_ConstraintTrigger_a_58220748 for constraint fk_filename: time=3.474 calls=1"
"Trigger RI_ConstraintTrigger_a_58220760 for constraint 1356_11407_fk_filename: time=7.003 calls=1"
"Trigger RI_ConstraintTrigger_a_58220800 for constraint fk_filename: time=3.905 calls=1"
"Trigger RI_ConstraintTrigger_a_58220812 for constraint 1357_11411_fk_filename: time=6.710 calls=1"
"Trigger RI_ConstraintTrigger_a_58220852 for constraint fk_filename: time=3.990 calls=1"
"Trigger RI_ConstraintTrigger_a_58220864 for constraint 1358_11415_fk_filename: time=6.525 calls=1"
"Trigger RI_ConstraintTrigger_a_58220904 for constraint fk_filename: time=3.735 calls=1"
"Trigger RI_ConstraintTrigger_a_58220916 for constraint 1359_11419_fk_filename: time=5.808 calls=1"
"Trigger RI_ConstraintTrigger_a_58220967 for constraint fk_filename: time=3.842 calls=1"
"Trigger RI_ConstraintTrigger_a_58220979 for constraint 1360_11423_fk_filename: time=6.655 calls=1"
"Trigger RI_ConstraintTrigger_a_58221022 for constraint fk_filename: time=4.667 calls=1"
"Trigger RI_ConstraintTrigger_a_58221034 for constraint 1361_11427_fk_filename: time=5.479 calls=1"
"Trigger RI_ConstraintTrigger_a_58221074 for constraint fk_filename: time=3.547 calls=1"
"Trigger RI_ConstraintTrigger_a_58221086 for constraint 1362_11431_fk_filename: time=6.817 calls=1"
"Trigger RI_ConstraintTrigger_a_58221126 for constraint fk_filename: time=3.961 calls=1"
"Trigger RI_ConstraintTrigger_a_58221138 for constraint 1363_11435_fk_filename: time=6.503 calls=1"
"Trigger RI_ConstraintTrigger_a_58221178 for constraint fk_filename: time=3.757 calls=1"
"Trigger RI_ConstraintTrigger_a_58221190 for constraint 1364_11439_fk_filename: time=7.066 calls=1"
"Trigger RI_ConstraintTrigger_a_58221237 for constraint fk_filename: time=3.910 calls=1"
"Trigger RI_ConstraintTrigger_a_58221249 for constraint 1365_11443_fk_filename: time=6.597 calls=1"
"Trigger RI_ConstraintTrigger_a_58221291 for constraint fk_filename: time=4.284 calls=1"
"Trigger RI_ConstraintTrigger_a_58221303 for constraint 1366_11447_fk_filename: time=7.540 calls=1"
"Trigger RI_ConstraintTrigger_a_58221343 for constraint fk_filename: time=3.479 calls=1"
"Trigger RI_ConstraintTrigger_a_58221355 for constraint 1367_11451_fk_filename: time=5.321 calls=1"
"Trigger RI_ConstraintTrigger_a_58221395 for constraint fk_filename: time=4.172 calls=1"
"Trigger RI_ConstraintTrigger_a_58221407 for constraint 1368_11455_fk_filename: time=5.331 calls=1"
"Trigger RI_ConstraintTrigger_a_58221447 for constraint fk_filename: time=3.464 calls=1"
"Trigger RI_ConstraintTrigger_a_58221459 for constraint 1369_11459_fk_filename: time=5.503 calls=1"
"Trigger RI_ConstraintTrigger_a_58221499 for constraint fk_filename: time=3.790 calls=1"
"Trigger RI_ConstraintTrigger_a_58221511 for constraint 1370_11463_fk_filename: time=5.402 calls=1"
"Trigger RI_ConstraintTrigger_a_58221551 for constraint fk_filename: time=3.582 calls=1"
"Trigger RI_ConstraintTrigger_a_58221563 for constraint 1371_11467_fk_filename: time=7.325 calls=1"
"Trigger RI_ConstraintTrigger_a_58221603 for constraint fk_filename: time=3.486 calls=1"
"Trigger RI_ConstraintTrigger_a_58221621 for constraint 1372_11471_fk_filename: time=6.640 calls=1"
"Trigger RI_ConstraintTrigger_a_58221665 for constraint fk_filename: time=5.134 calls=1"
"Trigger RI_ConstraintTrigger_a_58221677 for constraint 1373_11475_fk_filename: time=4.919 calls=1"
"Trigger RI_ConstraintTrigger_a_58221717 for constraint fk_filename: time=3.374 calls=1"
"Trigger RI_ConstraintTrigger_a_58221729 for constraint 1374_11479_fk_filename: time=5.891 calls=1"
"Trigger RI_ConstraintTrigger_a_58221769 for constraint fk_filename: time=3.690 calls=1"
"Trigger RI_ConstraintTrigger_a_58221781 for constraint 1375_11483_fk_filename: time=6.095 calls=1"
"Trigger RI_ConstraintTrigger_a_58221834 for constraint fk_filename: time=4.093 calls=1"
"Trigger RI_ConstraintTrigger_a_58221846 for constraint 1376_11487_fk_filename: time=6.956 calls=1"
"Trigger RI_ConstraintTrigger_a_58221886 for constraint fk_filename: time=3.675 calls=1"
"Trigger RI_ConstraintTrigger_a_58221898 for constraint 1377_11491_fk_filename: time=42.609 calls=1"
"Trigger RI_ConstraintTrigger_a_58221938 for constraint fk_filename: time=24.221 calls=1"
"Trigger RI_ConstraintTrigger_a_58221950 for constraint 1378_11495_fk_filename: time=7.879 calls=1"
"Trigger RI_ConstraintTrigger_a_58221990 for constraint fk_filename: time=6.555 calls=1"
"Trigger RI_ConstraintTrigger_a_58222002 for constraint 1379_11499_fk_filename: time=7.765 calls=1"
"Trigger RI_ConstraintTrigger_a_58222042 for constraint fk_filename: time=5.678 calls=1"
"Trigger RI_ConstraintTrigger_a_58222054 for constraint 1380_11503_fk_filename: time=8.225 calls=1"
"Trigger RI_ConstraintTrigger_a_58222105 for constraint fk_filename: time=7.696 calls=1"
"Trigger RI_ConstraintTrigger_a_58222118 for constraint 1381_11507_fk_filename: time=9.930 calls=1"
"Trigger RI_ConstraintTrigger_a_58222158 for constraint fk_filename: time=5.197 calls=1"
"Trigger RI_ConstraintTrigger_a_58222170 for constraint 1382_11511_fk_filename: time=8.397 calls=1"
"Trigger RI_ConstraintTrigger_a_58222210 for constraint fk_filename: time=4.494 calls=1"
"Trigger RI_ConstraintTrigger_a_58222222 for constraint 1383_11515_fk_filename: time=8.280 calls=1"
"Trigger RI_ConstraintTrigger_a_58222262 for constraint fk_filename: time=4.100 calls=1"
"Trigger RI_ConstraintTrigger_a_58222274 for constraint 1384_11519_fk_filename: time=6.736 calls=1"
"Trigger RI_ConstraintTrigger_a_58222314 for constraint fk_filename: time=3.823 calls=1"
"Trigger RI_ConstraintTrigger_a_58222326 for constraint 1385_11523_fk_filename: time=6.443 calls=1"
"Trigger RI_ConstraintTrigger_a_58222366 for constraint fk_filename: time=4.324 calls=1"
"Trigger RI_ConstraintTrigger_a_58222378 for constraint 1386_11527_fk_filename: time=7.069 calls=1"
"Trigger RI_ConstraintTrigger_a_58222426 for constraint fk_filename: time=3.873 calls=1"
"Trigger RI_ConstraintTrigger_a_58222441 for constraint 1387_11531_fk_filename: time=5.298 calls=1"
"Trigger RI_ConstraintTrigger_a_58222495 for constraint fk_filename: time=3.607 calls=1"
"Trigger RI_ConstraintTrigger_a_58222507 for constraint 1388_11535_fk_filename: time=5.445 calls=1"
"Trigger RI_ConstraintTrigger_a_58222547 for constraint fk_filename: time=3.445 calls=1"
"Trigger RI_ConstraintTrigger_a_58222559 for constraint 1389_11539_fk_filename: time=6.043 calls=1"
"Trigger RI_ConstraintTrigger_a_58222599 for constraint fk_filename: time=3.774 calls=1"
"Trigger RI_ConstraintTrigger_a_58222611 for constraint 1390_11543_fk_filename: time=6.550 calls=1"
"Trigger RI_ConstraintTrigger_a_58222651 for constraint fk_filename: time=3.030 calls=1"
"Trigger RI_ConstraintTrigger_a_58222663 for constraint 1391_11547_fk_filename: time=6.151 calls=1"
"Trigger RI_ConstraintTrigger_a_58222703 for constraint fk_filename: time=2.958 calls=1"
"Trigger RI_ConstraintTrigger_a_58222715 for constraint 1392_11551_fk_filename: time=5.232 calls=1"
"Trigger RI_ConstraintTrigger_a_58222755 for constraint fk_filename: time=2.855 calls=1"
"Trigger RI_ConstraintTrigger_a_58222767 for constraint 1393_11555_fk_filename: time=6.605 calls=1"
"Trigger RI_ConstraintTrigger_a_58222807 for constraint fk_filename: time=3.003 calls=1"
"Trigger RI_ConstraintTrigger_a_58222820 for constraint 1394_11559_fk_filename: time=5.206 calls=1"
"Trigger RI_ConstraintTrigger_a_58222870 for constraint fk_filename: time=3.330 calls=1"
"Trigger RI_ConstraintTrigger_a_58222882 for constraint 1395_11563_fk_filename: time=5.927 calls=1"
"Trigger RI_ConstraintTrigger_a_58222922 for constraint fk_filename: time=2.889 calls=1"
"Trigger RI_ConstraintTrigger_a_58222934 for constraint 1396_11567_fk_filename: time=4.461 calls=1"
"Trigger RI_ConstraintTrigger_a_58222974 for constraint fk_filename: time=3.121 calls=1"
"Trigger RI_ConstraintTrigger_a_58222986 for constraint 1397_11571_fk_filename: time=6.212 calls=1"
"Trigger RI_ConstraintTrigger_a_58223026 for constraint fk_filename: time=3.290 calls=1"
"Trigger RI_ConstraintTrigger_a_58223041 for constraint 1398_11575_fk_filename: time=4.182 calls=1"
"Trigger RI_ConstraintTrigger_a_58223082 for constraint fk_filename: time=3.112 calls=1"
"Trigger RI_ConstraintTrigger_a_58223094 for constraint 1399_11579_fk_filename: time=4.665 calls=1"
"Trigger RI_ConstraintTrigger_a_58223134 for constraint fk_filename: time=3.981 calls=1"
"Trigger RI_ConstraintTrigger_a_58223146 for constraint 1400_11583_fk_filename: time=4.189 calls=1"
"Trigger RI_ConstraintTrigger_a_58223186 for constraint fk_filename: time=3.079 calls=1"
"Trigger RI_ConstraintTrigger_a_58223198 for constraint 1401_11587_fk_filename: time=4.541 calls=1"
"Trigger RI_ConstraintTrigger_a_58223245 for constraint fk_filename: time=2.959 calls=1"
"Trigger RI_ConstraintTrigger_a_58223257 for constraint 1402_11591_fk_filename: time=4.356 calls=1"
"Trigger RI_ConstraintTrigger_a_58223283 for constraint 1403_11595_fk_filename: time=3.154 calls=1"
"Trigger RI_ConstraintTrigger_a_58223325 for constraint fk_filename: time=4.479 calls=1"
"Trigger RI_ConstraintTrigger_a_58223337 for constraint 1404_11599_fk_filename: time=3.324 calls=1"
"Trigger RI_ConstraintTrigger_a_58223377 for constraint fk_filename: time=4.157 calls=1"
"Trigger RI_ConstraintTrigger_a_58223389 for constraint 1405_11603_fk_filename: time=3.124 calls=1"
"Trigger RI_ConstraintTrigger_a_58223429 for constraint fk_filename: time=4.307 calls=1"
"Trigger RI_ConstraintTrigger_a_58223441 for constraint 1406_11607_fk_filename: time=3.558 calls=1"
"Trigger RI_ConstraintTrigger_a_58223492 for constraint fk_filename: time=5.441 calls=1"
"Trigger RI_ConstraintTrigger_a_58223504 for constraint 1407_11611_fk_filename: time=3.754 calls=1"
"Trigger RI_ConstraintTrigger_a_58223544 for constraint fk_filename: time=6.559 calls=1"
"Trigger RI_ConstraintTrigger_a_58223556 for constraint 1408_11615_fk_filename: time=4.170 calls=1"
"Trigger RI_ConstraintTrigger_a_58223597 for constraint fk_filename: time=4.274 calls=1"
"Trigger RI_ConstraintTrigger_a_58223609 for constraint 1409_11619_fk_filename: time=3.089 calls=1"
"Trigger RI_ConstraintTrigger_a_58223649 for constraint fk_filename: time=5.058 calls=1"
"Trigger RI_ConstraintTrigger_a_58223661 for constraint 1410_11623_fk_filename: time=3.503 calls=1"
"Trigger RI_ConstraintTrigger_a_58223701 for constraint fk_filename: time=5.118 calls=1"
"Trigger RI_ConstraintTrigger_a_58223713 for constraint 1411_11627_fk_filename: time=3.357 calls=1"
"Trigger RI_ConstraintTrigger_a_58223753 for constraint fk_filename: time=5.676 calls=1"
"Trigger RI_ConstraintTrigger_a_58223765 for constraint 1412_11631_fk_filename: time=3.256 calls=1"
"Trigger RI_ConstraintTrigger_a_58223816 for constraint fk_filename: time=4.124 calls=1"
"Trigger RI_ConstraintTrigger_a_58223828 for constraint 1413_11635_fk_filename: time=3.042 calls=1"
"Trigger RI_ConstraintTrigger_a_58223873 for constraint fk_filename: time=4.542 calls=1"
"Trigger RI_ConstraintTrigger_a_58223885 for constraint 1414_11639_fk_filename: time=3.285 calls=1"
"Trigger RI_ConstraintTrigger_a_58223925 for constraint fk_filename: time=5.209 calls=1"
"Trigger RI_ConstraintTrigger_a_58223937 for constraint 1415_11643_fk_filename: time=3.122 calls=1"
"Trigger RI_ConstraintTrigger_a_58223977 for constraint fk_filename: time=5.885 calls=1"
"Trigger RI_ConstraintTrigger_a_58223989 for constraint 1416_11647_fk_filename: time=3.509 calls=1"
"Trigger RI_ConstraintTrigger_a_58224029 for constraint fk_filename: time=4.560 calls=1"
"Trigger RI_ConstraintTrigger_a_58224041 for constraint 1417_11651_fk_filename: time=3.316 calls=1"
"Trigger RI_ConstraintTrigger_a_58224081 for constraint fk_filename: time=4.583 calls=1"
"Trigger RI_ConstraintTrigger_a_58224093 for constraint 1418_11655_fk_filename: time=3.329 calls=1"
"Trigger RI_ConstraintTrigger_a_58224133 for constraint fk_filename: time=4.157 calls=1"
"Trigger RI_ConstraintTrigger_a_58224149 for constraint 1419_11659_fk_filename: time=3.167 calls=1"
"Trigger RI_ConstraintTrigger_a_58224192 for constraint fk_filename: time=4.309 calls=1"
"Trigger RI_ConstraintTrigger_a_58224204 for constraint 1420_11663_fk_filename: time=3.371 calls=1"
"Trigger RI_ConstraintTrigger_a_58224247 for constraint fk_filename: time=5.212 calls=1"
"Trigger RI_ConstraintTrigger_a_58224259 for constraint 1421_11667_fk_filename: time=3.257 calls=1"
"Trigger RI_ConstraintTrigger_a_58224299 for constraint fk_filename: time=4.430 calls=1"
"Trigger RI_ConstraintTrigger_a_58224311 for constraint 1422_11671_fk_filename: time=3.589 calls=1"
"Trigger RI_ConstraintTrigger_a_58224351 for constraint fk_filename: time=5.288 calls=1"
"Trigger RI_ConstraintTrigger_a_58224363 for constraint 1423_11675_fk_filename: time=3.152 calls=1"
"Trigger RI_ConstraintTrigger_a_58224403 for constraint fk_filename: time=5.619 calls=1"
"Trigger RI_ConstraintTrigger_a_58224415 for constraint 1424_11679_fk_filename: time=3.796 calls=1"
"Trigger RI_ConstraintTrigger_a_58224460 for constraint fk_filename: time=5.503 calls=1"
"Trigger RI_ConstraintTrigger_a_58224472 for constraint 1425_11683_fk_filename: time=3.139 calls=1"
"Trigger RI_ConstraintTrigger_a_58224512 for constraint fk_filename: time=6.265 calls=1"
"Trigger RI_ConstraintTrigger_a_58224524 for constraint 1426_11687_fk_filename: time=3.292 calls=1"
"Trigger RI_ConstraintTrigger_a_58224564 for constraint fk_filename: time=4.223 calls=1"
"Trigger RI_ConstraintTrigger_a_58224576 for constraint 1427_11691_fk_filename: time=3.112 calls=1"
"Trigger RI_ConstraintTrigger_a_58224616 for constraint fk_filename: time=6.118 calls=1"
"Trigger RI_ConstraintTrigger_a_58224628 for constraint 1428_11695_fk_filename: time=3.361 calls=1"
"Trigger RI_ConstraintTrigger_a_58224668 for constraint fk_filename: time=5.639 calls=1"
"Trigger RI_ConstraintTrigger_a_58224680 for constraint 1429_11699_fk_filename: time=3.106 calls=1"
"Trigger RI_ConstraintTrigger_a_58224720 for constraint fk_filename: time=5.693 calls=1"
"Trigger RI_ConstraintTrigger_a_58224732 for constraint 1430_11703_fk_filename: time=3.172 calls=1"
"Trigger RI_ConstraintTrigger_a_58224788 for constraint fk_filename: time=4.919 calls=1"
"Trigger RI_ConstraintTrigger_a_58224805 for constraint 1431_11707_fk_filename: time=3.101 calls=1"
"Trigger RI_ConstraintTrigger_a_58224845 for constraint fk_filename: time=5.822 calls=1"
"Trigger RI_ConstraintTrigger_a_58224857 for constraint 1432_11711_fk_filename: time=3.769 calls=1"
"Trigger RI_ConstraintTrigger_a_58224897 for constraint fk_filename: time=4.935 calls=1"
"Trigger RI_ConstraintTrigger_a_58224909 for constraint 1433_11715_fk_filename: time=3.604 calls=1"
"Trigger RI_ConstraintTrigger_a_58224949 for constraint fk_filename: time=5.002 calls=1"
"Trigger RI_ConstraintTrigger_a_58224961 for constraint 1434_11719_fk_filename: time=3.447 calls=1"
"Trigger RI_ConstraintTrigger_a_58225001 for constraint fk_filename: time=4.479 calls=1"
"Trigger RI_ConstraintTrigger_a_58225013 for constraint 1435_11723_fk_filename: time=4.274 calls=1"
"Trigger RI_ConstraintTrigger_a_58225053 for constraint fk_filename: time=8.053 calls=1"
"Trigger RI_ConstraintTrigger_a_58225065 for constraint 1436_11727_fk_filename: time=9.265 calls=1"
"Trigger RI_ConstraintTrigger_a_58225105 for constraint fk_filename: time=3.783 calls=1"
"Trigger RI_ConstraintTrigger_a_58225117 for constraint 1437_11731_fk_filename: time=5.919 calls=1"
"Trigger RI_ConstraintTrigger_a_58225170 for constraint fk_filename: time=3.343 calls=1"
"Trigger RI_ConstraintTrigger_a_58225182 for constraint 1438_11735_fk_filename: time=5.461 calls=1"
"Trigger RI_ConstraintTrigger_a_58225222 for constraint fk_filename: time=3.203 calls=1"
"Trigger RI_ConstraintTrigger_a_58225234 for constraint 1439_11739_fk_filename: time=3.177 calls=1"
"Trigger RI_ConstraintTrigger_a_58225274 for constraint fk_filename: time=2.994 calls=1"
"Trigger RI_ConstraintTrigger_a_58225286 for constraint 1440_11743_fk_filename: time=5.852 calls=1"
"Trigger RI_ConstraintTrigger_a_58225342 for constraint fk_filename: time=3.455 calls=1"
"Trigger RI_ConstraintTrigger_a_58225354 for constraint 1441_11747_fk_filename: time=4.543 calls=1"
"Trigger RI_ConstraintTrigger_a_58225394 for constraint fk_filename: time=4.346 calls=1"
"Trigger RI_ConstraintTrigger_a_58225406 for constraint 1442_11751_fk_filename: time=3.716 calls=1"
"Trigger RI_ConstraintTrigger_a_58225446 for constraint fk_filename: time=5.577 calls=1"
"Trigger RI_ConstraintTrigger_a_58225458 for constraint 1443_11755_fk_filename: time=3.179 calls=1"
"Trigger RI_ConstraintTrigger_a_58225498 for constraint fk_filename: time=5.563 calls=1"
"Trigger RI_ConstraintTrigger_a_58225510 for constraint 1444_11759_fk_filename: time=3.696 calls=1"
"Trigger RI_ConstraintTrigger_a_58225550 for constraint fk_filename: time=4.453 calls=1"
"Trigger RI_ConstraintTrigger_a_58225562 for constraint 1445_11763_fk_filename: time=3.684 calls=1"
"Trigger RI_ConstraintTrigger_a_58225602 for constraint fk_filename: time=4.439 calls=1"
"Trigger RI_ConstraintTrigger_a_58225614 for constraint 1446_11767_fk_filename: time=5.292 calls=1"
"Trigger RI_ConstraintTrigger_a_58225654 for constraint fk_filename: time=4.199 calls=1"
"Trigger RI_ConstraintTrigger_a_58225666 for constraint 1447_11771_fk_filename: time=3.172 calls=1"
"Trigger RI_ConstraintTrigger_a_58225716 for constraint fk_filename: time=3.869 calls=1"
"Trigger RI_ConstraintTrigger_a_58225728 for constraint 1448_11775_fk_filename: time=3.511 calls=1"
"Trigger RI_ConstraintTrigger_a_58225768 for constraint fk_filename: time=4.242 calls=1"
"Trigger RI_ConstraintTrigger_a_58225780 for constraint 1449_11779_fk_filename: time=3.312 calls=1"
"Trigger RI_ConstraintTrigger_a_58225820 for constraint fk_filename: time=3.941 calls=1"
"Trigger RI_ConstraintTrigger_a_58225832 for constraint 1450_11783_fk_filename: time=3.266 calls=1"
"Trigger RI_ConstraintTrigger_a_58225879 for constraint fk_filename: time=5.646 calls=1"
"Trigger RI_ConstraintTrigger_a_58225891 for constraint 1451_11787_fk_filename: time=3.369 calls=1"
"Trigger RI_ConstraintTrigger_a_58225931 for constraint fk_filename: time=5.267 calls=1"
"Trigger RI_ConstraintTrigger_a_58225948 for constraint 1452_11791_fk_filename: time=3.817 calls=1"
"Trigger RI_ConstraintTrigger_a_58225988 for constraint fk_filename: time=4.204 calls=1"
"Trigger RI_ConstraintTrigger_a_58226000 for constraint 1453_11795_fk_filename: time=3.111 calls=1"
"Trigger RI_ConstraintTrigger_a_58226040 for constraint fk_filename: time=3.945 calls=1"
"Trigger RI_ConstraintTrigger_a_58226052 for constraint 1454_11799_fk_filename: time=3.180 calls=1"
"Trigger RI_ConstraintTrigger_a_58226092 for constraint fk_filename: time=4.331 calls=1"
"Trigger RI_ConstraintTrigger_a_58226104 for constraint 1455_11803_fk_filename: time=3.110 calls=1"
"Trigger RI_ConstraintTrigger_a_58226144 for constraint fk_filename: time=4.097 calls=1"
"Trigger RI_ConstraintTrigger_a_58226165 for constraint 1456_11807_fk_filename: time=3.308 calls=1"
"Trigger RI_ConstraintTrigger_a_58226206 for constraint fk_filename: time=5.616 calls=1"
"Trigger RI_ConstraintTrigger_a_58226218 for constraint 1457_11811_fk_filename: time=3.323 calls=1"
"Trigger RI_ConstraintTrigger_a_58226270 for constraint fk_filename: time=5.329 calls=1"
...
"Execution Time: 2550.275 ms"


来源: stackexchange

问:
Set up a search group with regular expressions that match one or two numeric values, but do not match any more immediately following numeric values

import re

input_text = "del 2065 de 42 52 de 200 de 2222 25 de 25 del 26. o del 8"  #example input

num_pattern = r"(\d{1,2})"
identification_regex = r"(?:del|de[\s|]*el|de|)[\s|]*" + num_pattern

input_text = re.sub(identification_regex, "AA", input_text)

print(repr(input_text)) # --> output
```
<p>This is the <strong>wrong output</strong> that I am getting if I use this search regex pattern for the numeric values identification in the input string</p>
```'AAAA AAAA AAAA AAAAAA AA AA. o AA'
```
<p>Since this is a simplification of a program, it has simplified the logic to just replace by <code>"AA"</code>, and this is the <strong>output</strong> we should get. In this output you can be noted that if there are more than 2 immediately consecutive numerical values, the replacement is not performed.</p>
```"del 2065 AA AA de 200 de 2222 AA AA AA. o AA"
```

The problem with this search pattern r"(\d{1,2})" is that while it succeeds in capturing 2 numeric digits correctly, the problem is that it captures even when there are numbers of 4 or more digits immediately following each other.

What kind of additional constraint do I need to put on the character search pattern for the match and replace algorithm to work correctly?

ContentLicense: CC BY-SA 4.0

Body:
import re

input_text = "del 2065 de 42 52 de 200 de 2222 25 de 25 del 26. o del 8"  #example input

num_pattern = r"(\d{1,2})"
identification_regex = r"(?:del|de[\s|]*el|de|)[\s|]*" + num_pattern

input_text = re.sub(identification_regex, "AA", input_text)

print(repr(input_text)) # --> output

This is the wrong output that I am getting if I use this search regex pattern for the numeric values identification in the input string

'AAAA AAAA AAAA AAAAAA AA AA. o AA'

Since this is a simplification of a program, it has simplified the logic to just replace by "AA", and this is the output we should get. In this output you can be noted that if there are more than 2 immediately consecutive numerical values, the replacement is not performed.

"del 2065 AA AA de 200 de 2222 AA AA AA. o AA"

The problem with this search pattern r"(\d{1,2})" is that while it succeeds in capturing 2 numeric digits correctly, the problem is that it captures even when there are numbers of 4 or more digits immediately following each other.

What kind of additional constraint do I need to put on the character search pattern for the match and replace algorithm to work correctly?


问:
Including ejs partial with listner button not working; how to fix static?
I am trying to include a partial on the page with my backend coming later. I want to use an event listener button. It dosent work. I am using express.ejs and node.js with vanilla js.

I am using this for my vanilla js

```<code>const button = document.getElementById('button')

button.addEventListener('click',()=>{
    const hi = document.createElement(`<%-require('../views/partials/hi.ejs')%>`)

    document.appendChild(hi)
})
</code>```

this for my html

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>hi</title>
    <link rel="stylesheet" href="main.css">
</head>
<body>

<button id="button">Im a button</button>

<script src="main.js" type="module"></script>
</body>
</html>
</code>```

and this for my node

```<code>const express = require('express')
const app = express()
app.set('view engine','ejs')
app.use(express.static('public'))

app.get('/',(req,res)=>{
    res.render('layout')
})

app.listen(5000,()=>{
    console.log('server listening')
})
</code>```

I get this error when i try to use the partial with the button

```<code>
main.js:4 Uncaught DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('<%-require('../views/partials/hi.ejs')%>') is not a valid name.
    at HTMLButtonElement.<anonymous> (http://localhost:5000/main.js:4:25)
</code>```

this comes from client side....why and how to fix?

Body:
I am trying to include a partial on the page with my backend coming later. I want to use an event listener button. It dosent work. I am using express.ejs and node.js with vanilla js.

I am using this for my vanilla js

const button = document.getElementById('button')

button.addEventListener('click',()=>{
    const hi = document.createElement(`<%-require('../views/partials/hi.ejs')%>`)

    document.appendChild(hi)
})

this for my html

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>hi</title>
    <link rel="stylesheet" href="main.css">

<button id="button">Im a button</button>

and this for my node

const express = require('express')
const app = express()
app.set('view engine','ejs')
app.use(express.static('public'))

app.get('/',(req,res)=>{
    res.render('layout')
})

app.listen(5000,()=>{
    console.log('server listening')
})

I get this error when i try to use the partial with the button

main.js:4 Uncaught DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('<%-require('../views/partials/hi.ejs')%>') is not a valid name.
    at HTMLButtonElement.<anonymous> (http://localhost:5000/main.js:4:25)

this comes from client side....why and how to fix?


问:
Nx-Angular: What is the difference in micro-frontend vs library and when to use which?
I’m currently in the POC phase using NX, all angular apps. One will be brand new, and the other two applications will be migrated. I'm struggling with which to use where micro-frontend vs. library. Thanks in advance!

Should each be a micro-frontend as opposed to a lib?

If I wanted only one login, would that be a library module?

Do I need an application shell if I put all 3 MFEs* behind one login?

Since they’re all Ng apps, making an Auth lib would be the best(using
module federation)?


问:
Is there a way to test Laravel's email configuration to check if it connects with the server?
I am building a CMS-like installer for my laravel project. I have updated the laravel.env file.
Now, I want to test the email configuration, I end up getting this error:

This is my controller code:

```<code>    public function processEmailConfig(){
        // // Create tables
        // Artisan::call('migrate:fresh', ['--force' => true]);
        // // Run seeder
        // Artisan::call('db:seed', ['--force' => true]);
        $data = Validator::make(request()->all(), [
            'mail_host' => 'required',
            'mail_port' => 'required|numeric',
            'mail_username' => 'required',
            'mail_password' => 'required',
            'mail_encryption' => 'required',
            'mail_from' => 'required',
        ]);
        if($data->fails()){
            return response()->json(['errors'=>$data->errors()->all()]);
        }
        $data = $data->validated();
        $this::updateEnv('MAIL_HOST', $data['mail_host']);
        $this::updateEnv('MAIL_PORT', $data['mail_port']);
        $this::updateEnv('MAIL_USERNAME', $data['mail_username']);
        $this::updateEnv('MAIL_PASSWORD', $data['mail_password']);
        $this::updateEnv('MAIL_ENCRYPTION', $data['mail_encryption']);
        $this::updateEnv('MAIL_FROM_ADDRESS', $data['mail_from']);
        try {
            Mail::to('info@chibuezevince.me')->send(new WelcomeEmail);
        } catch (Exception $e) {
            return response()->json(['errors'=>['Incorrect Email Configuration']]);
        }
        return response()->json(['success'=>['Success']]);
    }
</code>```

Please, how do I go about it?

I tried:

```<code>        try {
            Mail::to('info@chibuezevince.me')->send(new WelcomeEmail);
        } catch (Exception $e) {
            return response()->json(['errors'=>['Incorrect Email Configuration']]);
        }
</code>```

But as you can see, it still gives the same error.

Body:
I am building a CMS-like installer for my laravel project. I have updated the laravel.env file.
Now, I want to test the email configuration, I end up getting this error:

This is my controller code:

    public function processEmailConfig(){
        // // Create tables
        // Artisan::call('migrate:fresh', ['--force' => true]);
        // // Run seeder
        // Artisan::call('db:seed', ['--force' => true]);
        $data = Validator::make(request()->all(), [
            'mail_host' => 'required',
            'mail_port' => 'required|numeric',
            'mail_username' => 'required',
            'mail_password' => 'required',
            'mail_encryption' => 'required',
            'mail_from' => 'required',
        ]);
        if($data->fails()){
            return response()->json(['errors'=>$data->errors()->all()]);
        }
        $data = $data->validated();
        $this::updateEnv('MAIL_HOST', $data['mail_host']);
        $this::updateEnv('MAIL_PORT', $data['mail_port']);
        $this::updateEnv('MAIL_USERNAME', $data['mail_username']);
        $this::updateEnv('MAIL_PASSWORD', $data['mail_password']);
        $this::updateEnv('MAIL_ENCRYPTION', $data['mail_encryption']);
        $this::updateEnv('MAIL_FROM_ADDRESS', $data['mail_from']);
        try {
            Mail::to('info@chibuezevince.me')->send(new WelcomeEmail);
        } catch (Exception $e) {
            return response()->json(['errors'=>['Incorrect Email Configuration']]);
        }
        return response()->json(['success'=>['Success']]);
    }

Please, how do I go about it?

I tried:

        try {
            Mail::to('info@chibuezevince.me')->send(new WelcomeEmail);
        } catch (Exception $e) {
            return response()->json(['errors'=>['Incorrect Email Configuration']]);
        }

But as you can see, it still gives the same error.


问:
how to identify a user who has several roles where each role has profile data in different microservices?
I'm currently refactoring from monolithic to microservice on the career platform application, but I encountered a problem because each module has an email password for each role and i want to make it a single sign on.

The roles in this application include:

Have profile data as a jobseeker

Have profile data as company admin

Have profile data as a freelancer

Have profile data as a training provider

With the data structure as below

jobseeker

id

e-mail

password

first_name

last_name

dob

location

...

company

id

company_name

location

industry

...

company_admin

id

e-mail

password

first_name

last_name

roles

...

trainer

id

trainer_name

type (trainer / training_center)

e-mail

password

location

...

freelancer

id

username

jobseeker_id

...

What's the best way to break down the profile data for each role and also combine it into a single user account? And how to implement into microservices?


问:
Telegram bot to configure TP-Link router that the device of user is connected to
I am trying to make a Telegram bot that can help user to configure TP-Link router like SSID, network password, reboot and other.
I already tried using https://github.com/epsi95/TPLink-Python on Google Colab but it checks connection of bot to server and the local IP that the user's device is connected to.

For example trying to connect to 192.168.0.1 actually is done on server side not the local network of user.

Is there any specific tool/platform or other script/language that can help to achieve this?

https://github.com/epsi95/TPLink-Python

```<code>def r_detail(update: Update, context: CallbackContext):
    update.message.reply_text(
        "Please Wait...")
    try:
        tp_client = TPLinkClient()
        router_details = tp_client.get_router_details()
        update.message.reply_text(
         router_details)
    except Exception as e:
        update.message.reply_text(str(e))
</code>```

HTTPConnectionPool(host='192.168.0.1', port=80): Max retries exceeded with url: /cgi?1&1&1&8 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fc7fda9f1f0>: Failed to establish a new connection: [Errno 110] Connection timed out'))

Body:
I am trying to make a Telegram bot that can help user to configure TP-Link router like SSID, network password, reboot and other.
I already tried using https://github.com/epsi95/TPLink-Python on Google Colab but it checks connection of bot to server and the local IP that the user's device is connected to.

For example trying to connect to 192.168.0.1 actually is done on server side not the local network of user.

Is there any specific tool/platform or other script/language that can help to achieve this?

https://github.com/epsi95/TPLink-Python

def r_detail(update: Update, context: CallbackContext):
    update.message.reply_text(
        "Please Wait...")
    try:
        tp_client = TPLinkClient()
        router_details = tp_client.get_router_details()
        update.message.reply_text(
         router_details)
    except Exception as e:
        update.message.reply_text(str(e))

HTTPConnectionPool(host='192.168.0.1', port=80): Max retries exceeded with url: /cgi?1&1&1&8 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fc7fda9f1f0>: Failed to establish a new connection: [Errno 110] Connection timed out'))


问:
Template only showing up in top left corner
I am trying to use templates in .html and when I load a template in, it is only showing up in a small area in the top left corner and giving me a scroll wheel to move around the small box. I am not sure what I am doing wrong, the code works perfectly fine in its own .html but when I try to use a template it doesn't.

template.html

```<code>    <style>
  .navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 500px;
    background-color: #333;
    color: #fff;
  }

  .navbar-item {
    cursor: pointer;
  }

  .navbar-item:hover {
    color: #eee;
  }
</style>

<nav class="navbar">
  <div class="navbar-item">Home</div>
  <div class="navbar-item">About</div>
  <div class="navbar-item">Contact</div>
</nav>
</code>```

index.html

```<code><html>
  <head>
    <meta charset="utf-8" />
    <title>My Navbar Template</title>
  </head>
  <body>
    <div id="navbar-container"></div>

    <script>
      var navbarContainer = document.getElementById('navbar-container');
      navbarContainer.innerHTML = '<object type="text/html" data="template.html"></object>';
    </script>
  </body>
</html>
</code>```

Body:
I am trying to use templates in .html and when I load a template in, it is only showing up in a small area in the top left corner and giving me a scroll wheel to move around the small box. I am not sure what I am doing wrong, the code works perfectly fine in its own .html but when I try to use a template it doesn't.

template.html

Home

About

Contact

index.html

    <meta charset="utf-8" />
    <title>My Navbar Template</title>


问:
Oracle Cloud Ubuntu GUI bandwidth 10x slower than shell
I have an Ubuntu instance running on Oracle Cloud.

Download speed via shell is around 2500 Mbps.
But via Firefox in GUI over RDP is only 200 Mbps.

Any reason for this? Is there some kind of throttling?


问:
Why are the log files of modern data storage formats like Delta and Apache Kafka topics left-padded with zeros up to 20 digits?
I am a data engineer who uses both Apache Kafka for streaming as well as Delta for storage on lakes.
This is more of a question to feed my curiosity. I can see both the Delta transaction log files (which are of .json extension ) as well as the Kafka topic log files (which are of .log extension) are named in the same way with zeros left padded up to 20 digit length.

E.g.:

00000000000000000000.log,00000000000000000001.log --> Kafka topic log files

00000000000000000000.json,00000000000000000001.json --> Delta transaction log files

Why the standard is 20 digit length? Why can't it be 19 or 21?


问:
system library disappeared
After installing R 4.2. and RStudio I can't see the system library (I do see the user library, however).
Here are my R and RStudio configurations:

```<code>Sys.info()
sysname        release        version       nodename        machine          login
user effective_user

 "Windows"       "10 x64"  "build 19044"   "MP01027922"       "x86-64"      "U468091"
 "U468091"      "U468091"

.libPaths()
[1] "C:/profili/u468091/Documents/Enterprise Analytics/R-4.2.2/library"

dir.exists(Sys.getenv("R_LIBS_USER"))
[1] FALSE  # why? the env variable 'R_LIBS_USER' is properly set up (see later)

Sys.getenv()
...
PATH
c:/rtools42/x86_64-w64-mingw32.static.posix/bin;
c:/rtools42/usr/bin;
...
PATHEXT
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
...
R_ARCH                                           /x64
R_CLI_HAS_HYPERLINK_IDE_HELP                     true
R_CLI_HAS_HYPERLINK_IDE_RUN                      true
R_CLI_HAS_HYPERLINK_IDE_VIGNETTE                 true
R_COMPILED_BY                                    gcc 10.4.0
R_DOC_DIR                                        c:/profili/u468091/DOCUME~1/ENTERP~1/R-42~1.2/doc
R_HOME                                           c:/profili/u468091/DOCUME~1/ENTERP~1/R-42~1.2
R_LIBS_SITE                                      c:/profili/u468091/DOCUME~1/ENTERP~1/R-42~1.2/site-library
R_LIBS_USER                                      C:\Users\u468091\AppData\Local/R/win-library/4.2
R_RTOOLS42_PATH                                  c:/rtools42/x86_64-w64-mingw32.static.posix/bin;c:/rtools42/usr/bin
R_USER                                           C:/profili/u468091/Documents
RMARKDOWN_MATHJAX_PATH                           c:/profili/u468091/Documents/Enterprise Analytics/rSTUDIO/resources/mathjax-27
RS_LOCAL_PEER                                    \\.\pipe\55470-rsession
RS_RPOSTBACK_PATH                                c:/profili/u468091/Documents/Enterprise Analytics/rSTUDIO/bin/rpostback
RS_SHARED_SECRET                                 1cc90387-55bd-426a-ab7d-3ef4b8b6eba3
RSTUDIO                                          1
RSTUDIO_CLI_HYPERLINKS                           true
RSTUDIO_CONSOLE_COLOR                            256
RSTUDIO_CONSOLE_WIDTH                            80
RSTUDIO_MSYS_SSH                                 c:/profili/u468091/Documents/Enterprise Analytics/rSTUDIO/bin/msys-ssh-1000-18
RSTUDIO_PANDOC                                   c:/profili/u468091/Documents/Enterprise Analytics/rSTUDIO/bin/quarto/bin/tools
RSTUDIO_PROGRAM_MODE                             desktop
RSTUDIO_SESSION_PID                              9444
RSTUDIO_SESSION_PORT                             55470
RSTUDIO_USER_IDENTITY                            U468091
RSTUDIO_WINUTILS                                 c:/profili/u468091/Documents/Enterprise Analytics/rSTUDIO/bin/winutils
...
</code>```

Any suggestions? There are a lot of posts out there related to R user library disappeared. None related to system library disappeared.
Many thanks in advance.

Title: system library disappeared

Body:
After installing R 4.2. and RStudio I can't see the system library (I do see the user library, however).
Here are my R and RStudio configurations:

Sys.info()
sysname        release        version       nodename        machine          login
user effective_user

 "Windows"       "10 x64"  "build 19044"   "MP01027922"       "x86-64"      "U468091"
 "U468091"      "U468091"

.libPaths()
[1] "C:/profili/u468091/Documents/Enterprise Analytics/R-4.2.2/library"

dir.exists(Sys.getenv("R_LIBS_USER"))
[1] FALSE  # why? the env variable 'R_LIBS_USER' is properly set up (see later)

Sys.getenv()
...
PATH
c:/rtools42/x86_64-w64-mingw32.static.posix/bin;
c:/rtools42/usr/bin;
...
PATHEXT
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
...
R_ARCH                                           /x64
R_CLI_HAS_HYPERLINK_IDE_HELP                     true
R_CLI_HAS_HYPERLINK_IDE_RUN                      true
R_CLI_HAS_HYPERLINK_IDE_VIGNETTE                 true
R_COMPILED_BY                                    gcc 10.4.0
R_DOC_DIR                                        c:/profili/u468091/DOCUME~1/ENTERP~1/R-42~1.2/doc
R_HOME                                           c:/profili/u468091/DOCUME~1/ENTERP~1/R-42~1.2
R_LIBS_SITE                                      c:/profili/u468091/DOCUME~1/ENTERP~1/R-42~1.2/site-library
R_LIBS_USER                                      C:\Users\u468091\AppData\Local/R/win-library/4.2
R_RTOOLS42_PATH                                  c:/rtools42/x86_64-w64-mingw32.static.posix/bin;c:/rtools42/usr/bin
R_USER                                           C:/profili/u468091/Documents
RMARKDOWN_MATHJAX_PATH                           c:/profili/u468091/Documents/Enterprise Analytics/rSTUDIO/resources/mathjax-27
RS_LOCAL_PEER                                    \\.\pipe\55470-rsession
RS_RPOSTBACK_PATH                                c:/profili/u468091/Documents/Enterprise Analytics/rSTUDIO/bin/rpostback
RS_SHARED_SECRET                                 1cc90387-55bd-426a-ab7d-3ef4b8b6eba3
RSTUDIO                                          1
RSTUDIO_CLI_HYPERLINKS                           true
RSTUDIO_CONSOLE_COLOR                            256
RSTUDIO_CONSOLE_WIDTH                            80
RSTUDIO_MSYS_SSH                                 c:/profili/u468091/Documents/Enterprise Analytics/rSTUDIO/bin/msys-ssh-1000-18
RSTUDIO_PANDOC                                   c:/profili/u468091/Documents/Enterprise Analytics/rSTUDIO/bin/quarto/bin/tools
RSTUDIO_PROGRAM_MODE                             desktop
RSTUDIO_SESSION_PID                              9444
RSTUDIO_SESSION_PORT                             55470
RSTUDIO_USER_IDENTITY                            U468091
RSTUDIO_WINUTILS                                 c:/profili/u468091/Documents/Enterprise Analytics/rSTUDIO/bin/winutils
...

Any suggestions? There are a lot of posts out there related to R user library disappeared. None related to system library disappeared.
Many thanks in advance.


问:
Javascript/typescript mapping function, advice on how to handle items not in mapping?
My coworkwer, who left recently, wrote this and I'm trying to understand how to best catch errors if an invalid key is passed to the parent function. This child function uses that key to map the call of another function to return appropriate formatting for currencies.

Fairly new to JavaScript, so this is challenging for me. It doesn't seem like I can easily call the key for the mapping I made in the numTypeMap function?

I tried calling keys on the object or use toString to see if it would output the mapping options in some way. I'm probably misunderstanding something basic about JS.

```<code>export const getFormattedValue = (
  value: number | null | undefined,
  numType: string,
  options?: { round?: boolean; expanded?: boolean }
): string => {
  if (value === null || value === undefined) {
    return '';
  }
  const numTypeMap: { [t: string]: (n: number, round?: boolean, expanded?: boolean) => string } = {
    number: toReadableNumber,
    percent: toReadablePercentage,
    dollar: toReadableDollar,
    canadianDollar: toReadableCanadianDollar,
    pound: toReadablePound,
    euro: toReadableEuro,
  };
  return numTypeMap[numType](value, options?.round, options?.expanded) as string;
};
</code>```

Body:
My coworkwer, who left recently, wrote this and I'm trying to understand how to best catch errors if an invalid key is passed to the parent function. This child function uses that key to map the call of another function to return appropriate formatting for currencies.

Fairly new to JavaScript, so this is challenging for me. It doesn't seem like I can easily call the key for the mapping I made in the numTypeMap function?

I tried calling keys on the object or use toString to see if it would output the mapping options in some way. I'm probably misunderstanding something basic about JS.

export const getFormattedValue = (
  value: number | null | undefined,
  numType: string,
  options?: { round?: boolean; expanded?: boolean }
): string => {
  if (value === null || value === undefined) {
    return '';
  }
  const numTypeMap: { [t: string]: (n: number, round?: boolean, expanded?: boolean) => string } = {
    number: toReadableNumber,
    percent: toReadablePercentage,
    dollar: toReadableDollar,
    canadianDollar: toReadableCanadianDollar,
    pound: toReadablePound,
    euro: toReadableEuro,
  };
  return numTypeMap[numType](value, options?.round, options?.expanded) as string;
};


问:
Stata non-obvious type mismatch error r(109)?
When calculating a date, a non-obvious error appears on line 103:

```<code>collapse (mean)  welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize
</code>```

I use stata 13

Project

```<code>clear all
set more off

global dirpath =  "C:\Users\kukiman\Documents\stata\code_and_data"

capture mkdir "$dirpath\tables"
capture mkdir "$dirpath\figures"
capture mkdir "$dirpath\figures\market_summary"
capture mkdir "$dirpath\figures\market_welfare_compare"
capture mkdir "$dirpath\figures\panel_figures"
capture mkdir "$dirpath\figures\synthesis"
capture mkdir "$dirpath\figures\temp_files"

*ssc install dm40
global numfirms = 3

global prices "5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 55.0 60.0 65.0"
global timeT = 30

if ($numfirms == 3) {
global cities "Cincinnati Detroit Minneapolis Pittsburgh SaltLakeCity Seattle"
}
else if ($numfirms == 4) {
global cities "Cincinnati Denver Detroit KansasCity Minneapolis NewYork Phoenix Pittsburgh SaltLakeCity SanFrancisco Seattle St.Louis"
}
else if ($numfirms == 5) {
global cities "Birmingham Chicago Cincinnati Dallas Denver Detroit Florida KansasCity Minneapolis NewYork Phoenix Pittsburgh SaltLakeCity SanFrancisco Seattle St.Louis"
}
else if ($numfirms == 6) {
global cities "Atlanta Baltimore Birmingham Chicago Cincinnati Dallas Denver Detroit Florida KansasCity LosAngeles Minneapolis NewYork Phoenix Pittsburgh SaltLakeCity SanAntonio SanFrancisco Seattle St.Louis"
}
else {
global cities "Minneapolis"
}

cd $dirpath

clear
set more off

cd  "$dirpath\data\"
gen mechanism = ""
save simulation_data_$numfirms.dta, replace

local city $cities
local permit $prices
local mechanism "Auctioning Grandfather Output BTA"

foreach x of local city {
    insheet using "`x'/`x'_Baseline_0.0.csv", clear
    capture destring averagerate
    capture destring runcs
    gen welfare = (runcs + profit + runcarbon)/1000
    gen averagefirms = (1*runonefirm + 2*runtwofirms + 3*runthreefirms + 4*runfourfirms+ 5*runfivefirms + 6*runsixfirms)/$timeT
    if ("`x'" == "SaltLakeCity" | "`x'" == "Pittsburgh" | "`x'" == "Dallas" | "`x'" == "Denver" | "`x'" == "St.Louis") {
        replace averagepricerun = averagepricerun * $timeT / ($timeT - runnofirms)
    }

    destring averagerate, replace force

    collapse (mean)  welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize
    *summarize welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize
    *describe  welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize

    rename runcs cs
    rename runcarbon carbonrevenue
    rename runemissions emissions
    rename runleakage leakage
    rename averagepricerun price
    rename averagefirms num_firms
    rename averagerate erate
    gen carbonprice = 0

    label var welfare "Domestic Welfare ($ in NPV) cs+carbonrev+profit"
    label var cs "Net Consumer Surplus ($ in NPV)"
    label var profit "Total Profit ($ in NPV)"
    label var carbonrevenue "Carbon Revenues ($ in NPV)"
    label var emissions "Discounted emissions (tons in NPV)"
    label var leakage "Discounted leakage (tons in NPV)"
    label var price "Average price ($)"
    label var carbonprice "Carbon price ($)"
    label var num_firms "Number of firms in the market"

    gen epa_market = "`x'"
    gen mechanism = "Baseline"
    order mechanism
    order epa_market

    append using simulation_data_$numfirms.dta
    save simulation_data_$numfirms.dta, replace

    foreach m of local mechanism {
        foreach t of local permit {
            insheet using "`x'/`x'_`m'_`t'.csv", clear
            capture destring averagerate
            capture destring runcs
            gen welfare = (runcs + profit + runcarbon)/1000
            if ("`m'" == "BTA") {
                replace welfare = welfare + `t'*runleakage/1000
            }
            gen averagefirms = (1*runonefirm + 2*runtwofirms + 3*runthreefirms + 4*runfourfirms+ 5*runfivefirms + 6*runsixfirms)/$timeT
            if ("`x'" == "SaltLakeCity" | "`x'" == "Pittsburgh" | "`x'" == "Dallas" | "`x'" == "Denver" | "`x'" == "St.Louis") {
                replace averagepricerun = averagepricerun * $timeT / ($timeT - runnofirms)
            }

            destring averagerate, replace force

            collapse (mean)  welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize
            *summarize welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize
            *describe welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize

            rename runcs cs
            rename runcarbon carbonrevenue
            rename runemissions emissions
            rename runleakage leakage
            rename averagepricerun price
            rename averagefirms num_firms
            rename averagerate erate

            gen carbonprice = `t'

            label var welfare "Domestic Welfare ($ in NPV) cs+carbonrev+profit"
            label var cs "Net Consumer Surplus ($ in NPV)"
            label var profit "Total Profit ($ in NPV)"
            label var carbonrevenue "Carbon Revenues ($ in NPV)"
            label var emissions "Discounted emissions (tons in NPV)"
            label var leakage "Discounted leakage (tons in NPV)"
            label var price "Average price ($)"
            label var carbonprice "Carbon price ($)"
            label var num_firms "Number of firms in the market"

            gen epa_market = "`x'"
            gen mechanism = "`m'"
            order mechanism
            order epa_market

            append using simulation_data_$numfirms.dta
            save simulation_data_$numfirms.dta, replace
        }
    }
}

qui do "$dirpath\stata_code\counterfactual_analysis\create_simulation_panel_data.do"
qui do "$dirpath\stata_code\counterfactual_analysis\create_simulation_capacity_data.do"
qui do "$dirpath\stata_code\counterfactual_analysis\create_dynamic_NPV.do"
/* INDIVIDUAL GRAPHS **********************************************************/
qui do "$dirpath\stata_code\counterfactual_analysis\dynamic_graphs_marketlevel.do"
/* MAIN ANALYSIS **************************************************************/
qui do "$dirpath\stata_code\counterfactual_analysis\synthesis.do"
qui do "$dirpath\stata_code\counterfactual_analysis\panel_analysis.do"
qui do "$dirpath\stata_code\counterfactual_analysis\optimal_tax.do"
qui do "$dirpath\stata_code\counterfactual_analysis\abatement.do"
</code>```

UPD1:
Changed in code: conv2num to destring; collapse to summarize and describe.

The error has changed to:

```<code>variable erate is str18 in master but float in using data
You could specify append's force option to ignore this string/numeric mismatch.  The using variable would then be treated as if it contained "".
r(106);
</code>```

What is interesting, this error disappears when we delete last 2 lines, but the file is still written anyway. The data estimation is still wrong.

```<code>append using simulation_data_$numfirms.dtasave
simulation_data_$numfirms.dta, replace
</code>```

Debug info:

The variable changes the data type, I tried changing it averagerate has all characters numeric; replaced as floar team, but not yet

UPD2: Updated the code. Command averagerate has all characters numeric; replaced as floar dont work,  but the command destring averagerate, replace force helped me. Unfortunately, my data has become more like the right, but still erroneous, compared to the control example

Body:
When calculating a date, a non-obvious error appears on line 103:

collapse (mean)  welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize

I use stata 13

Project

clear all
set more off

global dirpath =  "C:\Users\kukiman\Documents\stata\code_and_data"

capture mkdir "$dirpath\tables"
capture mkdir "$dirpath\figures"
capture mkdir "$dirpath\figures\market_summary"
capture mkdir "$dirpath\figures\market_welfare_compare"
capture mkdir "$dirpath\figures\panel_figures"
capture mkdir "$dirpath\figures\synthesis"
capture mkdir "$dirpath\figures\temp_files"

*ssc install dm40
global numfirms = 3

global prices "5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 55.0 60.0 65.0"
global timeT = 30

if ($numfirms == 3) {
global cities "Cincinnati Detroit Minneapolis Pittsburgh SaltLakeCity Seattle"
}
else if ($numfirms == 4) {
global cities "Cincinnati Denver Detroit KansasCity Minneapolis NewYork Phoenix Pittsburgh SaltLakeCity SanFrancisco Seattle St.Louis"
}
else if ($numfirms == 5) {
global cities "Birmingham Chicago Cincinnati Dallas Denver Detroit Florida KansasCity Minneapolis NewYork Phoenix Pittsburgh SaltLakeCity SanFrancisco Seattle St.Louis"
}
else if ($numfirms == 6) {
global cities "Atlanta Baltimore Birmingham Chicago Cincinnati Dallas Denver Detroit Florida KansasCity LosAngeles Minneapolis NewYork Phoenix Pittsburgh SaltLakeCity SanAntonio SanFrancisco Seattle St.Louis"
}
else {
global cities "Minneapolis"
}

cd $dirpath

clear
set more off

cd  "$dirpath\data\"
gen mechanism = ""
save simulation_data_$numfirms.dta, replace

local city $cities
local permit $prices
local mechanism "Auctioning Grandfather Output BTA"

foreach x of local city {
    insheet using "`x'/`x'_Baseline_0.0.csv", clear
    capture destring averagerate
    capture destring runcs
    gen welfare = (runcs + profit + runcarbon)/1000
    gen averagefirms = (1*runonefirm + 2*runtwofirms + 3*runthreefirms + 4*runfourfirms+ 5*runfivefirms + 6*runsixfirms)/$timeT
    if ("`x'" == "SaltLakeCity" | "`x'" == "Pittsburgh" | "`x'" == "Dallas" | "`x'" == "Denver" | "`x'" == "St.Louis") {
        replace averagepricerun = averagepricerun * $timeT / ($timeT - runnofirms)
    }

    destring averagerate, replace force

    collapse (mean)  welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize
    *summarize welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize
    *describe  welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize

    rename runcs cs
    rename runcarbon carbonrevenue
    rename runemissions emissions
    rename runleakage leakage
    rename averagepricerun price
    rename averagefirms num_firms
    rename averagerate erate
    gen carbonprice = 0

    label var welfare "Domestic Welfare ($ in NPV) cs+carbonrev+profit"
    label var cs "Net Consumer Surplus ($ in NPV)"
    label var profit "Total Profit ($ in NPV)"
    label var carbonrevenue "Carbon Revenues ($ in NPV)"
    label var emissions "Discounted emissions (tons in NPV)"
    label var leakage "Discounted leakage (tons in NPV)"
    label var price "Average price ($)"
    label var carbonprice "Carbon price ($)"
    label var num_firms "Number of firms in the market"

    gen epa_market = "`x'"
    gen mechanism = "Baseline"
    order mechanism
    order epa_market

    append using simulation_data_$numfirms.dta
    save simulation_data_$numfirms.dta, replace

    foreach m of local mechanism {
        foreach t of local permit {
            insheet using "`x'/`x'_`m'_`t'.csv", clear
            capture destring averagerate
            capture destring runcs
            gen welfare = (runcs + profit + runcarbon)/1000
            if ("`m'" == "BTA") {
                replace welfare = welfare + `t'*runleakage/1000
            }
            gen averagefirms = (1*runonefirm + 2*runtwofirms + 3*runthreefirms + 4*runfourfirms+ 5*runfivefirms + 6*runsixfirms)/$timeT
            if ("`x'" == "SaltLakeCity" | "`x'" == "Pittsburgh" | "`x'" == "Dallas" | "`x'" == "Denver" | "`x'" == "St.Louis") {
                replace averagepricerun = averagepricerun * $timeT / ($timeT - runnofirms)
            }

            destring averagerate, replace force

            collapse (mean)  welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize
            *summarize welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize
            *describe welfare runcs profit import_profit runcarbon runemissions runleakage averagepricerun averagefirms averagerate marketsize

            rename runcs cs
            rename runcarbon carbonrevenue
            rename runemissions emissions
            rename runleakage leakage
            rename averagepricerun price
            rename averagefirms num_firms
            rename averagerate erate

            gen carbonprice = `t'

            label var welfare "Domestic Welfare ($ in NPV) cs+carbonrev+profit"
            label var cs "Net Consumer Surplus ($ in NPV)"
            label var profit "Total Profit ($ in NPV)"
            label var carbonrevenue "Carbon Revenues ($ in NPV)"
            label var emissions "Discounted emissions (tons in NPV)"
            label var leakage "Discounted leakage (tons in NPV)"
            label var price "Average price ($)"
            label var carbonprice "Carbon price ($)"
            label var num_firms "Number of firms in the market"

            gen epa_market = "`x'"
            gen mechanism = "`m'"
            order mechanism
            order epa_market

            append using simulation_data_$numfirms.dta
            save simulation_data_$numfirms.dta, replace
        }
    }
}

qui do "$dirpath\stata_code\counterfactual_analysis\create_simulation_panel_data.do"
qui do "$dirpath\stata_code\counterfactual_analysis\create_simulation_capacity_data.do"
qui do "$dirpath\stata_code\counterfactual_analysis\create_dynamic_NPV.do"
/* INDIVIDUAL GRAPHS **********************************************************/
qui do "$dirpath\stata_code\counterfactual_analysis\dynamic_graphs_marketlevel.do"
/* MAIN ANALYSIS **************************************************************/
qui do "$dirpath\stata_code\counterfactual_analysis\synthesis.do"
qui do "$dirpath\stata_code\counterfactual_analysis\panel_analysis.do"
qui do "$dirpath\stata_code\counterfactual_analysis\optimal_tax.do"
qui do "$dirpath\stata_code\counterfactual_analysis\abatement.do"

UPD1:
Changed in code: conv2num to destring; collapse to summarize and describe.

The error has changed to:

variable erate is str18 in master but float in using data
You could specify append's force option to ignore this string/numeric mismatch.  The using variable would then be treated as if it contained "".
r(106);

What is interesting, this error disappears when we delete last 2 lines, but the file is still written anyway. The data estimation is still wrong.

append using simulation_data_$numfirms.dtasave
simulation_data_$numfirms.dta, replace

Debug info:

The variable changes the data type, I tried changing it averagerate has all characters numeric; replaced as floar team, but not yet

UPD2: Updated the code. Command averagerate has all characters numeric; replaced as floar dont work,  but the command destring averagerate, replace force helped me. Unfortunately, my data has become more like the right, but still erroneous, compared to the control example