Hi,

I've noticed that if there are a LOT of users on the site and a number of calls are made to get the current points of a user, it can get very slow. On closer inspection, I saw that there was no index created on the uid, tid pair in the userpoints table.

So an update would be (I can provide in patch format if that is preferred):

// To sigify that this is a drupal 6 update
function userpoints_update_6009() {
  $ret = array();
  db_add_index($ret, 'userpoints', 'uid_tid', array('uid', 'tid'));
  return $ret;
}

I'm not sure if a similar index in needed in userpoints_txn yet but I noticed a significant speed bump upon doing this change.

Comments

kbahey’s picture

Status: Active » Needs work

Good idea.

Can you roll a patch?

Also, you need to add this to the schema itself, so new installations would get it too.

As a bonus, a patch for 5.x-3.x-dev would be appreciated too ...

btmash’s picture

I'm attaching the patch for the 6.x version first (since I don't currently have 5.x on my local machine) - I'll look into the 5.x version as soon as I get some more time.

btmash’s picture

StatusFileSize
new909 bytes

Ack...I completely forgot to add the patch.

kbahey’s picture

Version: 6.x-1.x-dev » 5.x-3.x-dev
Status: Needs work » Patch (to be ported)

Thanks.

Committed to 6.x-1.x-dev.

btmash’s picture

StatusFileSize
new1.2 KB

Here is the patch for the 5.x version - please check and see that the patch makes sense (I did a diff with 5.3.x-dev).

btmash’s picture

Status: Patch (to be ported) » Needs review

Should have changed status...

kbahey’s picture

Status: Needs review » Fixed

Committed to 5.x-3.x-dev.

Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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