Skip to content

Instantly share code, notes, and snippets.

@lirantal
Created December 2, 2013 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lirantal/7746730 to your computer and use it in GitHub Desktop.
Save lirantal/7746730 to your computer and use it in GitHub Desktop.
Improving on OG (Organic Groups) module optimization - makes no sense to add an ORDER BY clause to the query which hinders on performance and not being used at all in the loop iteration for the object building.
diff --git a/src/drupal/profiles/drupal_commons/modules/contrib/og/og.module b/src/drupal/profiles/drupal_commons/modules/contrib/og/og.module
index 74d4f42..545575e 100644
--- a/src/drupal/profiles/drupal_commons/modules/contrib/og/og.module
+++ b/src/drupal/profiles/drupal_commons/modules/contrib/og/og.module
@@ -894,7 +894,7 @@ function og_get_subscriptions($uid, $min_is_active = 1, $reset = FALSE) {
array_unshift($types, $min_is_active);
array_unshift($types, $uid);
- $sql = "SELECT n.title, n.type, n.status, ou.* FROM {og_uid} ou INNER JOIN {node} n ON ou.nid = n.nid WHERE ou.uid = %d AND ou.is_active >= %d AND n.type $in ORDER BY n.title";
+ $sql = "SELECT n.title, n.type, n.status, ou.* FROM {og_uid} ou INNER JOIN {node} n ON ou.nid = n.nid WHERE ou.uid = %d AND ou.is_active >= %d AND n.type $in";
$result = db_query($sql, $types);
while ($row = db_fetch_array($result)) {
$subscriptions[$uid][$min_is_active][$row['nid']] = $row;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment