Skip to content
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

Fix MariaDB list columns performance #6202

Merged
merged 5 commits into from
Nov 5, 2023

Conversation

ausi
Copy link
Contributor

@ausi ausi commented Oct 20, 2023

Q A
Type bug
Fixed issues contao/contao#6409

Summary

Starting with version 3.7.0 we noticed that the listTableColumns() method got very slow on some systems, our migrate command went from taking around 2 seconds with version 3.6 to 260 seconds with version3.7.

This is due to the LEFT JOIN information_schema.CHECK_CONSTRAINTS not getting optimized by MariaDB which causes the database server to scan every table of every database.

This pull request fixes that by using a subquery that is limited by WHERE CONSTRAINT_SCHEMA = $databaseName. This brings the performance back to where it was with version 3.6.

@fritzmg
Copy link

fritzmg commented Oct 20, 2023

Just to add more notes: this is especially noticeable in local development environments where you may have a lot of databases with lots of tables from various projects - as the unoptimized information_schema.CHECK_CONSTRAINTS query will then scan every table of every database every time, which is very slow. Thus exacerbating the issue when listTableColumns() is executed multiple times during database migrations as previously mentioned (hence the operation time sky rocketing from just 2 seconds to 260 seconds for example).

Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for picking this PR up so late.

src/Platforms/AbstractMySQLPlatform.php Outdated Show resolved Hide resolved
@ausi
Copy link
Contributor Author

ausi commented Nov 2, 2023

Sorry for picking this PR up so late.

Nothing to be sorry about! Thank you for all your work on doctrine!

@derrabus derrabus added this to the 3.7.2 milestone Nov 5, 2023
@ausi ausi force-pushed the fix/mariadb-list-columns-json branch from 3a01396 to 82d8266 Compare November 5, 2023 18:14
@ausi
Copy link
Contributor Author

ausi commented Nov 5, 2023

This should be ready now.

Followup pull requests:

  1. Deprecation in 3.8: Deprecate AbstractMySQLPlatform::getColumnTypeSQLSnippets() #6213
  2. Removal in 4.0: Remove AbstractMySQLPlatform::getColumnTypeSQLSnippets() #6214

@ausi ausi requested a review from derrabus November 5, 2023 19:17
@derrabus derrabus merged commit 1f1aad9 into doctrine:3.7.x Nov 5, 2023
82 checks passed
derrabus added a commit that referenced this pull request Nov 5, 2023
* 3.7.x:
  Fix MariaDB list columns performance (#6202)
@ausi ausi deleted the fix/mariadb-list-columns-json branch November 5, 2023 19:34
derrabus added a commit that referenced this pull request Nov 5, 2023
|      Q       |   A
|------------- | -----------
| Type         | improvement
| Fixed issues |
#6202 (comment)

#### Summary

Deprecates `AbstractMySQLPlatform::getColumnTypeSQLSnippets()`

~~Needs to be rebased after #6202
got merged upstream.~~ Done.

---------

Co-authored-by: Alexander M. Turek <me@derrabus.de>
derrabus added a commit to derrabus/dbal that referenced this pull request Nov 5, 2023
* 3.8.x:
  Deprecate AbstractMySQLPlatform::getColumnTypeSQLSnippets() (doctrine#6213)
  Fix MariaDB list columns performance (doctrine#6202)
derrabus added a commit to derrabus/dbal that referenced this pull request Nov 11, 2023
* 3.8.x:
  Enable skipping locked rows in QueryBuilder
  Fix coding standard violation
  Remove unused unit test fixtures
  Add Oracle v23 to CI testing (doctrine#6217)
  Extend `AbstractMySQLPlatform::getColumnTypeSQLSnippets()` deprecation layer (doctrine#6215)
  Deprecate AbstractMySQLPlatform::getColumnTypeSQLSnippets() (doctrine#6213)
  Fix MariaDB list columns performance (doctrine#6202)
derrabus added a commit to derrabus/dbal that referenced this pull request Nov 11, 2023
* 3.8.x:
  Enable skipping locked rows in QueryBuilder
  Fix coding standard violation
  Remove unused unit test fixtures
  Add Oracle v23 to CI testing (doctrine#6217)
  Extend `AbstractMySQLPlatform::getColumnTypeSQLSnippets()` deprecation layer (doctrine#6215)
  Deprecate AbstractMySQLPlatform::getColumnTypeSQLSnippets() (doctrine#6213)
  Fix MariaDB list columns performance (doctrine#6202)
derrabus pushed a commit that referenced this pull request Nov 13, 2023
|      Q       |   A
|------------- | -----------
| Type         | feature
| Fixed issues |
#6202 (comment)

#### Summary

Removes `AbstractMySQLPlatform::getColumnTypeSQLSnippets()`

Needs to be rebased after #6202 and #6213 got merged upstream.
allan-simon pushed a commit to allan-simon/dbal that referenced this pull request Nov 13, 2023
|      Q       |   A
|------------- | -----------
| Type         | bug
| Fixed issues | contao/contao#6409

#### Summary

Starting with version 3.7.0 we noticed that the `listTableColumns()`
method got very slow on some systems, our migrate command went from
taking around 2 seconds with version 3.6 to 260 seconds with version3.7.

This is due to the `LEFT JOIN information_schema.CHECK_CONSTRAINTS` not
getting optimized by MariaDB which causes the database server to scan
every table of every database.

This pull request fixes that by using a subquery that is limited by
`WHERE CONSTRAINT_SCHEMA = $databaseName`. This brings the performance
back to where it was with version 3.6.
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this pull request Jan 12, 2024
Doctrine DBAL 3.7.0 introduced a performance issue [1]
which has been already fixed by the Doctrine Team [2].

This change updates the `doctrine/dbal` composer constraint
to ensure that this performance issue is gone.

Note:   The monorepo composer.lock already containted the
        3.7.2 bugfis release, therefore this has not been
        detected in casual core development. This update
        is to mitigate the performance issue at all costs
        for TYPO3 users.

As a sideeffect, this should put `composerInstallMin`
nightly function tests on speed again.

Used command(s):

> composer require --no-update --no-install \
    -d typo3/sysext/redirects \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/core \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/install \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update \
    "doctrine/dbal":"^3.7.2" ; \
  composer update --lock

[1] contao/contao#6409
[2] doctrine/dbal#6202

Resolves: #102830
Releases: main, 12.4
Change-Id: If8b09f9556f11cc0fda4690f81343fc6c5d5e476
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82449
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this pull request Jan 12, 2024
Doctrine DBAL 3.7.0 introduced a performance issue [1]
which has been already fixed by the Doctrine Team [2].

This change updates the `doctrine/dbal` composer constraint
to ensure that this performance issue is gone.

Note:   The monorepo composer.lock already containted the
        3.7.2 bugfis release, therefore this has not been
        detected in casual core development. This update
        is to mitigate the performance issue at all costs
        for TYPO3 users.

As a sideeffect, this should put `composerInstallMin`
nightly function tests on speed again.

Used command(s):

> composer require --no-update --no-install \
    -d typo3/sysext/redirects \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/core \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/install \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update \
    "doctrine/dbal":"^3.7.2" ; \
  composer update --lock

[1] contao/contao#6409
[2] doctrine/dbal#6202

Resolves: #102830
Releases: main, 12.4
Change-Id: If8b09f9556f11cc0fda4690f81343fc6c5d5e476
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82448
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Garvin Hicking <gh@faktor-e.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Stefan Bürk <stefan@buerk.tech>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this pull request Jan 12, 2024
Doctrine DBAL 3.7.0 introduced a performance issue [1]
which has been already fixed by the Doctrine Team [2].

This change updates the `doctrine/dbal` composer constraint
to ensure that this performance issue is gone.

Note:   The monorepo composer.lock already containted the
        3.7.2 bugfis release, therefore this has not been
        detected in casual core development. This update
        is to mitigate the performance issue at all costs
        for TYPO3 users.

As a sideeffect, this should put `composerInstallMin`
nightly function tests on speed again.

Used command(s):

> composer require --no-update --no-install \
    -d typo3/sysext/redirects \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/core \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/install \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update \
    "doctrine/dbal":"^3.7.2" ; \
  composer update --lock

[1] contao/contao#6409
[2] doctrine/dbal#6202

Resolves: #102830
Releases: main, 12.4
Change-Id: If8b09f9556f11cc0fda4690f81343fc6c5d5e476
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82449
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
TYPO3IncTeam pushed a commit to TYPO3-CMS/install that referenced this pull request Jan 12, 2024
Doctrine DBAL 3.7.0 introduced a performance issue [1]
which has been already fixed by the Doctrine Team [2].

This change updates the `doctrine/dbal` composer constraint
to ensure that this performance issue is gone.

Note:   The monorepo composer.lock already containted the
        3.7.2 bugfis release, therefore this has not been
        detected in casual core development. This update
        is to mitigate the performance issue at all costs
        for TYPO3 users.

As a sideeffect, this should put `composerInstallMin`
nightly function tests on speed again.

Used command(s):

> composer require --no-update --no-install \
    -d typo3/sysext/redirects \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/core \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/install \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update \
    "doctrine/dbal":"^3.7.2" ; \
  composer update --lock

[1] contao/contao#6409
[2] doctrine/dbal#6202

Resolves: #102830
Releases: main, 12.4
Change-Id: If8b09f9556f11cc0fda4690f81343fc6c5d5e476
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82449
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
TYPO3IncTeam pushed a commit to TYPO3-CMS/redirects that referenced this pull request Jan 12, 2024
Doctrine DBAL 3.7.0 introduced a performance issue [1]
which has been already fixed by the Doctrine Team [2].

This change updates the `doctrine/dbal` composer constraint
to ensure that this performance issue is gone.

Note:   The monorepo composer.lock already containted the
        3.7.2 bugfis release, therefore this has not been
        detected in casual core development. This update
        is to mitigate the performance issue at all costs
        for TYPO3 users.

As a sideeffect, this should put `composerInstallMin`
nightly function tests on speed again.

Used command(s):

> composer require --no-update --no-install \
    -d typo3/sysext/redirects \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/core \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/install \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update \
    "doctrine/dbal":"^3.7.2" ; \
  composer update --lock

[1] contao/contao#6409
[2] doctrine/dbal#6202

Resolves: #102830
Releases: main, 12.4
Change-Id: If8b09f9556f11cc0fda4690f81343fc6c5d5e476
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82449
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this pull request Jan 12, 2024
Doctrine DBAL 3.7.0 introduced a performance issue [1]
which has been already fixed by the Doctrine Team [2].

This change updates the `doctrine/dbal` composer constraint
to ensure that this performance issue is gone.

Note:   The monorepo composer.lock already containted the
        3.7.2 bugfis release, therefore this has not been
        detected in casual core development. This update
        is to mitigate the performance issue at all costs
        for TYPO3 users.

As a sideeffect, this should put `composerInstallMin`
nightly function tests on speed again.

Used command(s):

> composer require --no-update --no-install \
    -d typo3/sysext/redirects \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/core \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/install \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update \
    "doctrine/dbal":"^3.7.2" ; \
  composer update --lock

[1] contao/contao#6409
[2] doctrine/dbal#6202

Resolves: #102830
Releases: main, 12.4
Change-Id: If8b09f9556f11cc0fda4690f81343fc6c5d5e476
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82448
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Garvin Hicking <gh@faktor-e.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Stefan Bürk <stefan@buerk.tech>
TYPO3IncTeam pushed a commit to TYPO3-CMS/install that referenced this pull request Jan 12, 2024
Doctrine DBAL 3.7.0 introduced a performance issue [1]
which has been already fixed by the Doctrine Team [2].

This change updates the `doctrine/dbal` composer constraint
to ensure that this performance issue is gone.

Note:   The monorepo composer.lock already containted the
        3.7.2 bugfis release, therefore this has not been
        detected in casual core development. This update
        is to mitigate the performance issue at all costs
        for TYPO3 users.

As a sideeffect, this should put `composerInstallMin`
nightly function tests on speed again.

Used command(s):

> composer require --no-update --no-install \
    -d typo3/sysext/redirects \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/core \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/install \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update \
    "doctrine/dbal":"^3.7.2" ; \
  composer update --lock

[1] contao/contao#6409
[2] doctrine/dbal#6202

Resolves: #102830
Releases: main, 12.4
Change-Id: If8b09f9556f11cc0fda4690f81343fc6c5d5e476
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82448
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Garvin Hicking <gh@faktor-e.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Stefan Bürk <stefan@buerk.tech>
TYPO3IncTeam pushed a commit to TYPO3-CMS/redirects that referenced this pull request Jan 12, 2024
Doctrine DBAL 3.7.0 introduced a performance issue [1]
which has been already fixed by the Doctrine Team [2].

This change updates the `doctrine/dbal` composer constraint
to ensure that this performance issue is gone.

Note:   The monorepo composer.lock already containted the
        3.7.2 bugfis release, therefore this has not been
        detected in casual core development. This update
        is to mitigate the performance issue at all costs
        for TYPO3 users.

As a sideeffect, this should put `composerInstallMin`
nightly function tests on speed again.

Used command(s):

> composer require --no-update --no-install \
    -d typo3/sysext/redirects \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/core \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update --no-install \
    -d typo3/sysext/install \
    "doctrine/dbal":"^3.7.2" ; \
  composer require --no-update \
    "doctrine/dbal":"^3.7.2" ; \
  composer update --lock

[1] contao/contao#6409
[2] doctrine/dbal#6202

Resolves: #102830
Releases: main, 12.4
Change-Id: If8b09f9556f11cc0fda4690f81343fc6c5d5e476
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82448
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Garvin Hicking <gh@faktor-e.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants