# Forums | Mahara Community

## Developers / Speed up profile save and reduce load

Deleted user
Posts: 117

10 September 2009, 8:11 PM

You can speed up the profile saving and reduce the load on the server by making a very slight change to your /artefact/internal/index.php file.

Open /artefact/internal/index.php and find in the profileform_submit function:

else {
$classname = generate_artefact_class_name($element);
$profile = new$classname(0, array('owner' => $USER->get('id')));$profile->set('title', $values[$element]);
$profile->commit(); } and change it to: else { if ($values[$element] !=$profilefields[$element]){$classname = generate_artefact_class_name($element);$profile = new $classname(0, array('owner' =>$USER->get('id')));
$profile->set('title',$values[$element]);$profile->commit();
}
}

This will only update in the database the artefacts that have been changed, rather than updating all of them, which will speed up the entire process and reduce the load on the server.  This will also make the mtime field more relevant, since it will be accurately be recording when an artefact has been modified.

Deleted user
Posts: 1643
##### Re: Speed up profile save and reduce load

13 September 2009, 10:56 PM

Good spotting! I have now applied that patch to master
Deleted user
Posts: 117
##### Re: Speed up profile save and reduce load

14 September 2009, 5:12 AM

Actually, it should probably be:

if (!isset($profilefields[$element]) || $values[$element] != $profilefields[$element]){

because if $profilefields[$element] is not set, it will log an error as an unknown array index.

Although, I haven't checked other sections, similar modifications can probably be done several other places, too.

Deleted user
Posts: 1643
##### Re: Speed up profile save and reduce load

14 September 2009, 4:47 PM

Indeed - I guess first profile save for new users would cause that problem. I've committed a fix for that too.

It might be better off being fixed in the artefact base class - so calling set() with the same data doesn't change anything internally, meaning commit() does nothing.

We haven't really looked too hard into stuff like that yet because we haven't noticed any performance issues so far in that area - instead, we've been playing performance whack-a-mole (fixing slow things when they appear). One day I'll stop being lazy and crank out xdebug and see what's going on

4 results