Repository navigation
refactor: de-normalize per-query method classification to a varchar column - #48
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Existing installations lack the migration needed by the new method-column inserts and queries.
Review effort: Balanced
Findings: 1
What changed in this PR
Simplifies slowlog method classification by storing method names directly, complementing #47’s separate import-memory fix.
Changes:
- Replaces method IDs with names and moves classifier fragments into PHP constants.
- Removes method-dictionary joins from statistics, charts, and detail queries.
- Updates classification tests and the changelog.
| File | Description |
|---|---|
| tests/Unit/OtherTablesClassificationTest.php | Asserts named classification buckets. |
| tests/Integration/ImportPostProcessMethodsTest.php | Verifies method-name inserts and classifications. |
| slowlog.php | Filters and displays methods by name. |
| includes/slowlog_functions.php | Uses method constants and simplifies read queries. |
| includes/database.php | Changes the association table’s create-time schema. |
| CHANGELOG.md | Documents the de-normalization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
plugin_slowlog_details_methods stored a methodid FK into the plugin_slowlog_methods dictionary, forcing a join on every stats/chart/details/scope read path and a dictionary lookup during import. Store the method name directly in a new method varchar column, drive classification from a PHP constant (SLOWLOG_METHOD_FRAGMENTS), and drop the plugin_slowlog_methods joins. The dictionary tables are left created-but-unused (a clean install drops them). Tests updated to assert method names; plugin_slowlog_stats cache is unchanged.
…ant details-list DISTINCT plugin_slowlog_tables was written on import and cleared on remove/reprocess but never read - everything uses plugin_slowlog_details_tables - so remove its CREATE and all DML (the uninstall drop stays to clean up existing installs). Separately, the details list used SELECT DISTINCT sld.*; the association tables' composite PKs already make every join row unique, so the DISTINCT never removed a row and only forced a filesort/hash over the mediumtext query columns - dropped it.
TheWitness
force-pushed
the
refactor/denormalize-methods
branch
from
October 1, 2026 22:00
c1e4842 to
6ccbad5
Compare
bmfmancini
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Follow-up to #47 (the import memory fix). Addresses the over-normalization you flagged:
plugin_slowlog_details_methodsstored amethodidforeign key into theplugin_slowlog_methodsdictionary, so every read path (stats cache build, By Method chart, details list, method filter dropdown, chart-scope list) had to JOIN the dictionary, and import had to look method ids up.Changes
plugin_slowlog_details_methods.methodid(int FK) →methodvarchar(45), stored directly. Primary key is now(logid, logentry, method).plugin_slowlog_methodstable into a PHP constant,SLOWLOG_METHOD_FRAGMENTS;import_post_process()and the OTHER TABLES / OTHERS bucketing write the method name directly.slowlog_collect_stats_by_method(),slowlog_get_chart_object_live()(By Method), the details-list query inslowlog.php, the method filter dropdown, andslowlog_get_chart_scope_items()all now readplugin_slowlog_details_methods.methoddirectly — noplugin_slowlog_methodsjoin.plugin_slowlog_methodsandplugin_slowlog_tablesare still created (so upgrades don't error); per your note, a clean install drops them.plugin_slowlog_stats) — unchanged; it's already memory-safe (bounded reservoir + exact count/sum).Tests
ImportPostProcessMethodsTest/OtherTablesClassificationTestupdated to assert method names instead of ids, and the removedmethodid-lookup guard's test was dropped.ComputeStatsTest,SetupTableApiUsageTest,TableModeDispatchTest,PreparedStatementUsageTestpass unchanged.php -lclean on all changed files. No version bump; CHANGELOG updated under2.6.Note: this branches off
main(independent of #47); they touch different functions and merge cleanly.