On our site we have a number of subscriptions which are verified by uid - however, because the uid column is not indexed in simplenews_subscriptions, it was acting slow - the site became very fast after adding the index. The code for an update is:

/**
 * Addition of uid to simplenews_subscriptions
 */
function simplenews_update_6003() {
  $ret = array();
  db_add_index($ret, 'simplenews_subscriptions', 'uid', array('uid'));
  return $ret;
}

while the schema gets a new array entry:

'uid' => array('uid'),

Comments

sutharsan’s picture

Status: Active » Needs work

Can you explain to me where simplenews requires an index on uid in the simplenews_subscriptions table.

btmash’s picture

StatusFileSize
new875 bytes

I'm attaching the patch (its a patch from subversion though converting to cvs patch should be simple at this stage) so you can see the exact changes and where they go.

sutharsan’s picture

An upgrade is also required on the schema.
But WHY. Please explain where simplenews requires an index on uid in the simplenews_subscriptions table. What is the problem we are fixing here?

btmash’s picture

If you look at the patch, you'll see the line 'uid' => array('uid'). That is in the schema (look at the line number).

As for "WHY". On the various joins between the users table and the simplenews_subscriptions table (found in simplenews_send_node, simplenews_get_subscription) - on the queries done strictly against the uid (also in simplenews_get_subscription and a bunch of other places...most of them in the same place as where queries to check against the mail are)

The same case could be made against having an index for mail. Why is that there then?

sutharsan’s picture

StatusFileSize
new1.13 KB

Thanks for the explanation.
Comment simplenews_update_6003() changed.
Patch committed.

sutharsan’s picture

Status: Needs work » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.