Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.

Review main Work in progress Orphaned

74574[FEATURE] Add MySQL Explain to the admin panel

Christoph Lehmann CR -1 V -1 Normal +94 −1 updated 10/15/23, 20:21

Commit message

Explained SQL queries might give hints why queries are slow.
A typical case is a missing database index.

In the admin panel you now see explained SQL queries.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 10
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/74/74574/10 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/74/74574/10 && git cherry-pick FETCH_HEAD

Review

  • Code review CR -1 Needs a vote
    • Markus Klein -1
    • Stefan Bürk -1
  • Verified V -1 Blocked
    • core-ci -1 CI

Issues 1

Files 4

Review log 2838

Show 813 earlier messages
  1. Christoph Lehmann uploaded patch set 1 05/08/22, 16:37

  2. core-ci voted on patch set 1 V -1 05/08/22, 16:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27003

  3. Oliver Klee commented on patch set 1 05/08/22, 17:37

    locallang_debug.xlf:65

    Typo (both in the label key and the English localized string): Explaination -> Explanation
  4. Chris Müller commented on patch set 1 05/08/22, 18:24

    QueryInformation.php:142

    Why call by reference instead of returning the array? Returning the result makes clearer what is changed.

    QueryInformation.php:144

    connection and connectionPool are already available (line 66/67). Maybe add these as arguments to the method? Don't know if DI is possible in this class, this can also be an option.

    QueryInformation.php:163

    Why is the check for MySQL done again (see lines 145-147).

    QueryInformation.php:173

    explaination -> explanation

    QueryInformation.php:178

    explaination -> explanation

    QueryInformation.html:43

    explaination -> explanation also other places in template Why check index 0?
  5. Christoph Lehmann uploaded patch set 2 05/08/22, 19:19

  6. core-ci voted on patch set 2 V -1 05/08/22, 19:26 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27004

  7. Christoph Lehmann uploaded patch set 3 05/08/22, 19:54

  8. core-ci voted on patch set 3 V -1 05/08/22, 20:02 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27005

  9. Christoph Lehmann uploaded patch set 4 05/08/22, 20:04

  10. Christoph Lehmann commented on patch set 4 05/08/22, 20:07

    QueryInformation.php:142 Reply

    Done

    QueryInformation.php:144 Reply

    Done

    QueryInformation.php:163 Reply

    I wasn't finished. But yet :-)

    QueryInformation.php:173 Reply

    Done

    QueryInformation.php:178 Reply

    Done

    locallang_debug.xlf:65 Reply

    Thank you!

    QueryInformation.html:43 Reply

    Done
  11. core-ci voted on patch set 4 V -1 05/08/22, 20:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27006

  12. Christoph Lehmann uploaded patch set 5 05/08/22, 20:19

  13. core-ci voted on patch set 5 V +1 05/08/22, 20:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27007

  1. Oliver Klee commented on patch set 5 05/08/22, 20:28

    The subject line of the commit message should be an imperative about what the commit changes. In this case, I'd propose this subject: [FEATURE] Add MySQL Explain to the admin panel To learn more about how to write even better commit messages, I find this article very helpful: https://cbea.ms/git-commit/

    phpstan-baseline.neon:4

    Nice!

    QueryInformation.php:74

    I propose we make this even more explicit: - add a (very small) helper method usesMySql() - rename the enrichGroupedQueriesWithExplanations to make it explicit that this is MySQL-specific

    QueryInformation.php:144

    For the parameter array and the return array, please add more specific PHPDoc type annotations for the benefit of the reader and of static type analysis. (This will be particularly valuable when we raise the PHPStan level so that it requires details for each and every array.)

    QueryInformation.php:146

    In general, I'd propose not modifying the parameter, but instead using a new variable that then will be returned. This makes it more explicit to the reader if a variable is the parameter or the result.
  2. Christoph Lehmann uploaded patch set 6 05/08/22, 21:48

  3. core-ci voted on patch set 6 V +1 05/08/22, 21:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27009

  4. Christoph Lehmann commented on patch set 6 05/08/22, 21:57

    Reply

    Ack

    phpstan-baseline.neon:4 Reply

    Done

    QueryInformation.php:74 Reply

    >add a (very small) helper method usesMySql() Lets address this in another issue. There are currently 17x occurences in core which check the return value of getServerVersion() against MySQL/Xy.

    QueryInformation.php:144 Reply

    I added a PHPDoc. How would you describe something more specific when array could be array<int,string,array> ?

    QueryInformation.php:146 Reply

    Ack
  5. Simon Schaufelberger commented on patch set 6 CR -1 05/09/22, 00:07

    QueryInformation.html:55

    Indentation doesn't look correct here, at least in gerrit.
  6. Christoph Lehmann uploaded patch set 7 05/09/22, 07:32

  7. Christoph Lehmann commented on patch set 7 05/09/22, 07:32

    QueryInformation.html:55 Reply

    Good catch!
  8. core-ci voted on patch set 7 V +1 05/09/22, 07:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27015

  9. Oliver Klee commented on patch set 7 05/09/22, 09:47

    QueryInformation.php:144 Reply

    We at least know that the keys of the outer array are strings. So from reading the code, we know at least this: @param array<string, array<int, array<string, mixed>>> $groupedQueries result of groupQueries()
  10. Christoph Lehmann uploaded patch set 8 05/09/22, 17:48

  11. Christoph Lehmann commented on patch set 8 05/09/22, 17:51

    QueryInformation.php:144 Reply

    Hey Oliver, PHPStan complained about your proposal so i used my one. Feel free to improve it. In general i got your point ;-)
  12. core-ci voted on patch set 8 V -1 05/09/22, 17:55 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27043

  13. Andreas Kienast commented on patch set 8 CR -1 05/09/22, 19:09

    QueryInformation.php:73

    Can we use `$connection->getDatabasePlatform() instanceof AbstractMySQLPlatform` instead?
  14. Christoph Lehmann uploaded patch set 9 05/24/22, 06:58

  15. Christoph Lehmann commented on patch set 9 05/24/22, 07:00

    QueryInformation.php:73 Reply

    Done
  16. core-ci voted on patch set 9 V +1 05/24/22, 07:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27423

  17. Oliver Klee wrote 06/10/22, 21:43

    Removed cc Oliver Klee.
  18. Markus Klein commented on patch set 9 07/12/22, 11:32

    QueryInformation.html:71

    to my knowledge td has no scope attribute (it's not a header)
  19. Markus Klein commented on patch set 10 07/12/22, 11:32

    Published edit on patch set 9.
  20. Markus Klein commented on patch set 10 07/12/22, 11:33

    QueryInformation.html:71 Reply

    Done
  21. Markus Klein commented on patch set 10 CR -1 07/12/22, 11:37

    Shouldn't this be optional? Running EXPLAIN every time seems to be quote an overhead.
  22. core-ci voted on patch set 10 V -1 07/12/22, 11:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28967

  23. Stefan Bürk commented on patch set 10 CR -1 07/12/22, 11:56

    Reply Unresolved

    Basic idea of this patch is understandable, so thanks for it. However I'm not convinced of it: * "only" mysql => should cover all supported platforms. For main this should only be a switch for sqlite, as MariaDB, MySQL and Postgres supports `EXPLAIN`, sqlite `EXPLAIN QUERY PLAN` * The REGEXP to determine the table is not cross dbms and also do not cover if table identifier is not quoted (or has eventually other quote styles) as it checks for "`" * Should be definitly be optional. Would suggest to have a "button/action" per statement, and if clicked an modal opens doing only the explain for that query and shows the result. Besides this - patch should be "rebased" on current main - failing unit tests are unrelated (related to PHP BUG/CHANGE) which has been adjusted in core already.
  24. Oliver Klee commented on patch set 10 10/08/23, 13:44

    How should we proceed here?
  25. Christoph Lehmann marked it work in progress 10/15/23, 20:21