Before this change the query used an index scan to perform the
export, this could be really expensive on the database.
After the change the the query will use far more efficient joins,
on a large MySQL instance this can take minutes off of the query
time.
In additon the query was returning two columns that are not used
in the function. The layout column was causing the UNION to fail
on Oracle as it cannot compare text columns, removing these
columns from the returned data should further increase
performance further.
The existing query was inefficient using an index scan and
index merges. This change splits the query up into many individually
much more efficient queries.
This should significantly improve performance on large sites.
The UNION caused the query to be run in a way that is very
inefficient on MySQL, separating the queries causes each of them to
run in a much more efficient form.
Any duplicated will be filtered out on the PHP side instead of in
the database. On large Moodle sites this is preferable as the
extract is likely to be performed on a server dedicated to running
the Moodle cron and so there will be less of effect on resources
that are used to serve end users.
The UNION caused the query to be run in a way that is very
inefficient on MySQL, separating the queries causes each of them to
run in a much more efficient form.
Any duplicated will be filtered out on the PHP side instead of in
the database. On large Moodle sites this is preferable as the
extract is likely to be performed on a server dedicated to running
the Moodle cron and so there will be less of effect on resources
that are used to serve end users.
This change removes LEFT JOINS to improve the performance
when run against Moodle sites with very large data sets.
It will also cause some additional contexts to be returned:
1. When a user has modified a user_evidence_competency
without modifying its associated user_evidence record
This string became obsolete in Moodle 4.0 due to changes in course
navigation. Since then, it has remained unused and can now be safely
removed, as it is unlikely to be needed in the future.