Revision: 1977
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1977&view=rev
Author:   cimorrison
Date:     2011-09-21 15:16:25 +0000 (Wed, 21 Sep 2011)
Log Message:
-----------
Performance optimisation

Modified Paths:
--------------
    mrbs/branches/datatables/web/search.php

Modified: mrbs/branches/datatables/web/search.php
===================================================================
--- mrbs/branches/datatables/web/search.php     2011-09-21 14:58:20 UTC (rev 
1976)
+++ mrbs/branches/datatables/web/search.php     2011-09-21 15:16:25 UTC (rev 
1977)
@@ -285,28 +285,34 @@
   $search_pos = $total - ($total % $search["count"]);
 }
 
-// Now we set up the "real" query
-$sql = "SELECT E.id AS entry_id, E.create_by, E.name, E.description, 
E.start_time,
-               R.area_id, A.enable_periods
-          FROM $tbl_entry E, $tbl_room R, $tbl_area A
-         WHERE $sql_pred
-      ORDER BY E.start_time asc";
-// If it's an Ajax query we want everything.  Otherwise we use LIMIT to just 
get
-// the stuff we want.
-if (!$ajax)
+// If we're Ajax capable and this is not an Ajax request then don't ouput
+// the table body, because that's going to be sent later in response to
+// an Ajax request - so we don't need to do the query
+if (!$ajax_capable || $ajax)
 {
-  $sql .= " " . sql_syntax_limit($search["count"], $search_pos);
-}
+  // Now we set up the "real" query
+  $sql = "SELECT E.id AS entry_id, E.create_by, E.name, E.description, 
E.start_time,
+                 R.area_id, A.enable_periods
+            FROM $tbl_entry E, $tbl_room R, $tbl_area A
+           WHERE $sql_pred
+        ORDER BY E.start_time asc";
+  // If it's an Ajax query we want everything.  Otherwise we use LIMIT to just 
get
+  // the stuff we want.
+  if (!$ajax)
+  {
+    $sql .= " " . sql_syntax_limit($search["count"], $search_pos);
+  }
 
 
-// this is a flag to tell us not to display a "Next" link
-$result = sql_query($sql);
-if (! $result)
-{
-  trigger_error(sql_error(), E_USER_WARNING);
-  fatal_error(FALSE, get_vocab("fatal_db_error"));
+  // this is a flag to tell us not to display a "Next" link
+  $result = sql_query($sql);
+  if (! $result)
+  {
+    trigger_error(sql_error(), E_USER_WARNING);
+    fatal_error(FALSE, get_vocab("fatal_db_error"));
+  }
+  $num_records = sql_count($result);
 }
-$num_records = sql_count($result);
 
 if (!$ajax_capable)
 {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to