Skip to content

Commit

Permalink
MDL-17038 - refine query to limit size of returned data.
Browse files Browse the repository at this point in the history
Author: Peter Bulmer <peter.bulmer@catalyst.net.nz>
  • Loading branch information
peterbulmer committed Oct 30, 2008
1 parent 10610a6 commit e3c3610
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions auth/mnet/auth.php
Expand Up @@ -772,32 +772,28 @@ function keepalive_client() {
join("\n", $mnet_request->error));
break;
}

$query = "SELECT
l.id as remoteid,
l.time,
l.userid,
l.ip,
l.course,
l.module,
l.cmid,
l.action,
l.url,
l.info,
c.fullname as coursename,
c.modinfo as modinfo,
u.username
FROM
{$CFG->prefix}user u,
{$CFG->prefix}log l,
{$CFG->prefix}course c
WHERE
l.userid = u.id AND
u.mnethostid = '$mnethostid' AND
l.id > '".$mnet_request->response['last log id']."' AND
c.id = l.course
ORDER BY
remoteid ASC";
$query = '
SELECT
mhostlogs.remoteid, mhostlogs.time, mhostlogs.userid, mhostlogs.ip,
mhostlogs.course, mhostlogs.module, mhostlogs.cmid, mhostlogs.action,
mhostlogs.url, mhostlogs.info, mhostlogs.username, c.fullname as coursename,
c.modinfo
FROM
(
SELECT
l.id as remoteid, l.time, l.userid, l.ip, l.course, l.module, l.cmid,
l.action, l.url, l.info, u.username
FROM
' . $CFG->prefix . 'user u
INNER JOIN ' . $CFG->prefix . 'log l on l.userid = u.id
WHERE
u.mnethostid = $mnethostid
AND l.id > ' . $mnet_request->response['last log id'] . '
ORDER BY remoteid ASC
LIMIT 500
) mhostlogs
INNER JOIN ' . $CFG->prefix . 'course c on c.id = mhostlogs.course
ORDER by mhostlogs.remoteid ASC';

$results = get_records_sql($query);

Expand Down

0 comments on commit e3c3610

Please sign in to comment.