1
I’m doing a simple query on LMS Moodle to get the amount of hits from all users.
SELECT
count(userid) as total,
action,
userid
FROM
mdl_logstore_standard_log log
WHERE
action = 'loggedin'
GROUP BY
userid
The table involved has more than 500 thousand lines and the trend is only to increase.
I ran it 4, 5 minutes ago and it still hasn’t shown the results.
There is no way to do any optimization?
My knowledge is limited in Database Performance.
Add an index with the field
action
in this way:ALTER TABLE mdl_logstore_standard_log ADD INDEX IAction (action);
– Roberto de Campos
Put a EXPLAIN and tell us what the return is.
– UzumakiArtanis
Returns column names, types...
– Diego Souza
Only shows auto_increment in the primary key. In the rest of the columns it is empty.
– Diego Souza
@Robertofagundes worked the Index.
– Diego Souza
Okay, I’ll put it in answer.
– Roberto de Campos