Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.7.1
-
MOODLE_37_STABLE
-
MOODLE_37_STABLE
-
MDL-66599_master -
Description
When executing analytics models or analytics scheduled tasks, this query hangs because MySQL optimizer don't find a suitable index to use. Last execution was killed after more than 29000 s running.
The affected query is this:
SELECT u.*, ctx.id AS ctxid, ctx.path AS ctxpath, ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel, ctx.instanceid AS ctxinstance, ctx.locked AS ctxlocked
|
FROM user u
|
LEFT JOIN analytics_used_analysables aua ON u.id = aua.analysableid AND (aua.modelid = '3' OR aua.modelid IS NULL) |
JOIN context ctx ON (ctx.contextlevel = '30' AND ctx.instanceid = u.id) |
WHERE 1=1 AND u.deleted = '0' AND u.confirmed = '1' AND u.suspended = '0'; |
And this is the EXPLAIN result in moodle.org DB
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|
+----+-------------+-------+------------+--------+--------------------------------------------+-----------------+---------+----------------------+---------+----------+----------------------------------------------------+
|
| 1 | SIMPLE | u | NULL | ref | PRIMARY,user_deleted,user_confirmed | user_deleted | 1 | const | 1104191 | 5.00 | Using where | |
| 1 | SIMPLE | ctx | NULL | eq_ref | cont_conins_uix,instanceid | cont_conins_uix | 16 | const,moodleorg.u.id | 1 | 100.00 | Using index condition | |
| 1 | SIMPLE | aua | NULL | ALL | analusedanal_modact_ix,analusedanal_mod_ix | NULL | NULL | NULL | 81664 | 100.00 | Using where; Using join buffer (Block Nested Loop) | |
This query is located on core_analytics\local\analyser\base::get_iterator_sql()
Attachments
Issue Links
- is duplicated by
-
MDL-65424 Add missing unique indexes to analytics tables
-
- Closed
-