New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaced CREATE TEMPORARY TABLE ... LIKE
with different approach
#36022
Replaced CREATE TEMPORARY TABLE ... LIKE
with different approach
#36022
Conversation
…at doesn't conflict with MySQL 8
Hi @michalbiarda. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review. For more details, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento give me test instance |
Hi @michalbiarda. Thank you for your request. I'm working on Magento instance for you. |
Hi @michalbiarda, here is your Magento Instance: https://eb2c38a2f68947025bfccecf2d856c46.instances.magento-community.engineering |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
$temporaryTable = $this->quoteIdentifier($this->_getTableName($temporaryTableName)); | ||
$originTable = $this->quoteIdentifier($this->_getTableName($originTableName)); | ||
$sql = sprintf('CREATE TEMPORARY TABLE %s %s LIKE %s', $ifNotExistsSql, $temporaryTable, $originTable); | ||
$originCreate = $this->fetchPairs(sprintf('SHOW CREATE TABLE %s', $originTable)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$originCreate = $this->fetchPairs(sprintf('SHOW CREATE TABLE %s', $originTable)); | |
$originCreate = $this->fetchOne("SHOW CREATE TABLE {$originTable}"); |
You can use fetchOne to get result
Also sprintf is unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kandy Unfortunately I can't use fetchOne
because SHOW CREATE TABLE
returns two fields. First is table name, the second is SQL query.
I like you suggestion about sprintf
, though 👍.
@kandy I'm converting this PR to draft. I'll apply your suggestion about |
…nflict with MySQL 8
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Static Tests, Functional Tests EE |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
✔️ QA Passed Preconditions:
Manual testing scenario:
Actual Result: ✔️ Reindex command should run properly without any errors and frontend is accessible with categories and products. After: ✔️ Before: ✖️ Some functional tests are still failing hence moving this PR into extended testing. Thanks |
@magento run Functional Tests EE |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
@magento run Functional Tests EE |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
@magento create issue |
Moving back this PR to |
e947b85
into
magento:2.4-develop
Description (*)
Magento's MySQL adapter uses
CREATE TEMPORARY TABLE ... LIKE
command in\Magento\Framework\DB\Adapter\Pdo\Mysql::createTemporaryTableLike
.Newer versions of MySQL (8+) have problems with
CREATE TEMPORARY TABLE ... LIKE
, as you can read in the official documentation (https://dev.mysql.com/doc/refman/8.0/en/create-temporary-table.html):The documentation suggests to use
CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0
instead, but such command IS NOT an exact equivalent. It will create temporary table with the same fields, but will not create indexes. Without indexes performance of reindexing big amount of data is absurdly slow.I suggest to build
CREATE TEMPORARY TABLE
withoutLIKE
and withoutSELECT * FROM
. Here's my idea:Firstly use
SHOW CREATE TABLE
to get query for creation of source table (including indexes creation), and then modify it with PHP: changeCREATE TABLE
toCREATE TEMPORARY TABLE
, addIF NOT EXISTS
if necessary, removeTABLESPACE
definition if it exists, and replace source table name with temporary table name.Manual testing scenarios (*)
bin/magento index:reindex
.Contribution checklist (*)
Resolved issues:
CREATE TEMPORARY TABLE ... LIKE
with different approach #37926: ReplacedCREATE TEMPORARY TABLE ... LIKE
with different approach