From 6ff7d16b2537a0fd40376b75e90c9c5c5aa79dd7 Mon Sep 17 00:00:00 2001 From: peterbulmer Date: Thu, 30 Oct 2008 01:16:06 +0000 Subject: [PATCH] MDL-17038 - refine query to limit size of returned data. Author: Peter Bulmer --- auth/mnet/auth.php | 48 +++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php index b393526cc48..32b773ab4fa 100644 --- a/auth/mnet/auth.php +++ b/auth/mnet/auth.php @@ -772,32 +772,28 @@ class auth_plugin_mnet extends auth_plugin_base { 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 - {user} u, - {log} l, - {course} c - WHERE - l.userid = u.id AND - u.mnethostid = ? AND - l.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 + {user} u + INNER JOIN {log} l on l.userid = u.id + WHERE + u.mnethostid = ? + AND l.id > ? + ORDER BY remoteid ASC + LIMIT 500 + ) mhostlogs + INNER JOIN {course} c on c.id = mhostlogs.course + ORDER by mhostlogs.remoteid ASC"; $results = $DB->get_records_sql($query, array($mnethostid, $mnet_request->response['last log id']));