-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Issue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedProgress: rejectbug report
Description
In order to check foreign keys in separate databases for "Scalabale OMS" and "Scalable Checkout" modules Magento loads constraints from the database with the following query:
SELECT
`constraints`.`CONSTRAINT_NAME` AS `name`,
`info`.`TABLE_NAME` AS `table_name`,
`info`.`REFERENCED_TABLE_NAME` AS `reference_table_name`,
`info`.`COLUMN_NAME` AS `field_name`,
`info`.`REFERENCED_COLUMN_NAME` AS `reference_field_name`,
`constraints`.`DELETE_RULE` AS `delete_strategy`
FROM
`information_schema`.`KEY_COLUMN_USAGE` AS `info`
INNER JOIN `information_schema`.`REFERENTIAL_CONSTRAINTS` AS `constraints`
ON constraints.CONSTRAINT_NAME = info.CONSTRAINT_NAME AND constraints.CONSTRAINT_SCHEMA = info.CONSTRAINT_SCHEMA
WHERE
(info.REFERENCED_TABLE_NAME IS NOT NULL)
AND (info.CONSTRAINT_SCHEMA = '<Database Name>')
(See: \Magento\Framework\ForeignKey\Config\DbReader::getDbConstraints)
This query might take quite a long time (minutes) on a mysql server with many databases in use.
In our setup, which is the following:
> select count(*) from `information_schema`.`KEY_COLUMN_USAGE`;
| 66045 |
> select count(*) from `information_schema`.`REFERENTIAL_CONSTRAINTS`;
| 21222 |
this query takes: 1 min 26.70 sec.
It is also executed twice or more by Magento for each connection.
This makes the page load after clearing caches way too long and the website impossible to work with.
Preconditions
Magento EE 2.1.0 installed.
Mysql server with many databases 30+.
Steps to reproduce
- Clear cache in any way (cli, admin panel)
- Open any page (i.e. Homepage)
Expected result
The page takes few seconds to load.
Actual result
The page takes minutes to load.
mwgamble, thenguyenbluecom, deivua, elvinristi, hostep and 2 more
Metadata
Metadata
Assignees
Labels
Issue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedProgress: rejectbug report