When we install forum access we seem to have performance issues. I have run a utility mysql tuner, and it reports:
[!!] Joins performed without indexes: 12303

It then recommends to increase the join buffer size, or use indexes with joins. When I uninstall the forum access module this error goes away. I have also attached a screenshot.

I took a look in the mysql slow query log and it shows:

SELECT DISTINCT t.* FROM term_node r INNER JOIN term_data t ON r.tid = t.tid INNER JOIN vocabulary v ON t.vid = v.vid LEFT JOIN forum_access fa ON t.tid = fa.tid
LEFT JOIN acl acl_fa ON acl_fa.name = t.tid AND acl_fa.module = 'forum_access'
LEFT JOIN acl_user aclu_fa ON aclu_fa.acl_id = acl_fa.acl_id AND aclu_fa.uid = 0 WHERE ((fa.grant_view >= 1 AND fa.rid IN (1)) OR fa.tid IS NULL OR aclu_fa.uid = 0) AND ( r.vid = 44952 )ORDER BY v.weight, t.weight, t.name;

CommentFileSizeAuthor
tuner.gif52.61 KBwrender
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

salvis’s picture

Ok, so what do you propose?

wrender’s picture

I don't propose anything. I posted on here because I am looking for help. I think I may have found an issue with this module that maybe someone can fix?

salvis’s picture

Since you have the tools and the volume to investigate this, please look for a solution.

Try to add an index to the name column of the {acl} table. Does that make any difference?

Try to change the type of the name column in the {acl} table to int and add an index to it. Does that make any difference?

wrender’s picture

Adding an index to the name column of ACL and then changing it to an int has resolved the issue. Thank you. Should I post this in the ACL module area?

salvis’s picture

Project: Forum Access » ACL
Version: 6.x-1.5 » 6.x-1.x-dev

Do you see any noticeable effect other than some changes in your reports?

How did it look after adding the index but before changing to int?

wrender’s picture

we were having a lot of users complain that it was very slow to submit or reply to forum items. as well the mysql slow log query and application mysqltuner were reporting issues with non indexed joins.
I added the index, restarted mysql and it still reported joining issues. I then changed it to int and restart mysql and no more reports of mysql join index issues.

salvis’s picture

Ok, thank you. I'd still like to know whether you see a noticeable speed increase.

You now have a problem because you've changed your database scheme, which means you're running outside of the specs of ACL. DO NOT try to install any additional ACL client module which might expect name to accept strings.

wrender’s picture

When I made this adjustment, it did seem to improve the performance of the site. We have had an ongoing issue though, and I am not sure if it is related to the un-indexed inner joins. On an ongoing bases the site seems to get slower by the day after people have used it. Eventually if I restart the mysql services or the server it seems to speed things up. I wanted to fix this issue as it was reported as an issue by the mysqltuner software, and I had a feeling that it was contributing to the overall slow performance. As well I have another server with about 40 drupal websites on it, and none of those drupal websites report issues with joins being performed without indexes. So it really makes me believe there is something wrong with this site in particular.

Here is a more specific issue that has been happening:
When someone clicks "Save" to submit and save new content to the site, it takes almost 10-20 seconds for the post to actually go through.

I restarted the server this morning though, and this issue went away.

Currently the mysql slow query log is still reporting the odd join that is performed without indexes, and I am still trying to trace where that is happening.

salvis’s picture

That's pretty nasty behavior. Sounds like some kind of resource leak.

I'm very interested to find out whether this makes a noticeable difference because I implemented an integer column in the D7 version only a few days before your first post (#936682: Add a 'number' column to the {acl} table), and I wonder whether this should be backported to D6.

It's well-known that using node access modules causes a performance loss, but this is very difficult to quantify because it depends on many factors.

wrender’s picture

I will see if I can run some more tests when I have some more time and provide you with more information and numbers.

We are also running the domain access module to run affiliate sites, which is why I began to run the mysqltuner tool in the first place. The domain access module put such a load of queries that the page loading times got really really slow. After running the mysqltuner and making recommended adjustments it was about 300 times faster. (Although we still have this issue of bogging down over time). The sites in question are biglines.com and kickinghorsemagazine.com

wrender’s picture

salvis, do you know how I can easily identify joins that are performed without indexes from my slow query log? The mysqltuner is still reporting that joins are happening without indexes (Not as many as before). I am just not sure what to look for in the log specifically, was hoping that I could run something like tail -f -n 100 /var/lib/mysql/mysqlslow.log | grep -i INDEX to pull out the queries that are done on stuff not indexed. The following query below I noticed was still coming up about forum_access, and this seems to happen when I submit to the forum.

SELECT DISTINCT r.tid, COUNT(n.nid) AS topic_count, SUM(l.comment_count) AS comment_count
            FROM node n
            INNER JOIN node_comment_statistics l ON n.nid = l.nid
            INNER JOIN term_node r ON n.vid = r.vid
             INNER JOIN node_access na ON na.nid = n.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'domain_site') OR (na.gid = 0 AND na.realm = 'domain_id') OR (na.gid = 1 AND na.realm = 'forum_access'))) AND (  n.status = 1
            )GROUP BY r.tid;
salvis’s picture

You can install Devel and enable its query logging. Other than that I know very little about performance tuning.

The query you show is used when building the list of forums. It looks for 'forum_access' values in the realm column of the {node_access} table. It does not involve any FA or ACL table, only core tables.

salvis’s picture

We need to backport #936682: Add a 'number' column to the {acl} table to fix this permanently.

salvis’s picture

#936682: Add a 'number' column to the {acl} table has been committed to the -dev version (give it up to 12h to be repackaged).

Please update to the -dev version. You'll get an error when running the update 6002, because it can't create the index on the {acl.name} column, but you can ignore this (you already created this index manually).

This is an important first step. Please confirm when you've done it.

wrender’s picture

Ok. I have updated to the dev module of acl that was dated 11/25/2010

Drupal database update
user warning: Duplicate key name 'name' query: ALTER TABLE acl ADD INDEX name (name) in /home/biglines/public_html/includes/database.mysql-common.inc on line 434.

Updates were attempted. If you see no failures below, you may proceed happily to the administration pages. Otherwise, you may need to update your database manually. All errors have been logged.

    * Main page
    * Administration pages

The following queries were executed
acl module
Update #6002

    * ALTER TABLE {acl} ADD `number` INT DEFAULT NULL
    * Failed: ALTER TABLE {acl} ADD INDEX name (name)
    * ALTER TABLE {acl} ADD INDEX number (number)
salvis’s picture

Yes, that's fine. Exactly what we expected.

There are some FA issues that I have to take care of. Then there'll be a 6.x-1.3 release of ACL (most probably identical to the -dev version) and an update to FA, at which point you'll have to fix your database manually. Until then, please don't try to install any other contrib module that tries to use ACL.

I'll get back to you when it's ready.

wrender’s picture

Ok thank you. I still haven't been able to properly identify the indexes that are still happening on our website without joins. So it is difficult for me to tell if the ACL module was what was causing performance issues on the site. But I do believe that what you have fixed would most likely really improve the performance of the ACL and Forum Access modules.

salvis’s picture

Yes, I think so, too, but it would have been nice to get some actual data from a site under load.

salvis’s picture

@wrender: Please update to ACL 6.x-1.3. This will add a 'number' column to the {acl} table but not make any other changes yet. DON'T make any manual changes!

salvis’s picture

I've just committed a Forum Access update to the -dev version (give it up to 12h to be repackaged). This will move the 'name' column content to the 'number' column and then start using the 'number' column.

@wrender: Please make a backup copy of your site and update to the -dev version (in 12h!) of Forum Access. After running the update 6106, your {acl.name} column should be completely NULL. You can then change it back to VARCHAR(255), and you'll finally be back to the standard database scheme.

From then on you're again free to install other ACL client modules such as Content Access.

Please let me know how it goes.

wrender’s picture

We are just working on transferring the website to another server, and the backups need to be re-configured. I should be able to apply this in about a week.

Currently we are running ACL 6.x-1.2, and Forum Access 6.x-1.5. Should we be running ACL 6.x-1.x-dev?

salvis’s picture

ACL 6.x-1.x-dev is the same as 6.x-1.3. The releases are packaged immediately and the snapshots only every 12 hours, that's how they can get a different date, even if they have the same content.

So, please make sure you have a backup (as always), update to ACL 6.x-1.3 first and run update.php.

If all went well, then update to Forum Access 6.x-1.x-dev and proceed as explained in #20.

In a week is fine. This here will not make any difference performance-wise, but it'll bring you back into the fold. There'll be an ACL update after that, which should give us another performance increase.

wrender’s picture

Salvis,

I just went to upgrade ACL. It gives me an error, but I wasn't sure if this is what I should be expecting. Could you verify?

Drupal database update

    * user warning: Duplicate column name 'number' query: ALTER TABLE acl ADD `number` INT DEFAULT NULL in /home/biglines/public_html/includes/database.mysql-common.inc on line 298.
    * user warning: Duplicate key name 'name' query: ALTER TABLE acl ADD INDEX name (name) in /home/biglines/public_html/includes/database.mysql-common.inc on line 434.
    * user warning: Duplicate key name 'number' query: ALTER TABLE acl ADD INDEX number (number) in /home/biglines/public_html/includes/database.mysql-common.inc on line 434.

Updates were attempted. If you see no failures below, you may proceed happily to the administration pages. Otherwise, you may need to update your database manually. All errors have been logged.

    * Main page
    * Administration pages

The following queries were executed
acl module
Update #6002

    * Failed: ALTER TABLE {acl} ADD `number` INT DEFAULT NULL
    * Failed: ALTER TABLE {acl} ADD INDEX name (name)
    * Failed: ALTER TABLE {acl} ADD INDEX number (number)
wrender’s picture

Hi Salvis,

I also just installed the Forum Access 6.x-1.x-dev and followed your instructions from #20. The {acl.name} was indeed set to "INT" still. So I modified it back to VARCHAR.

Everything seems to be running correctly on the site. Maybe you could just verify if the error above was expected, and then we can proceed to testing performance.

Are there any specific commands you would like to execute on our server to test the performance?

salvis’s picture

No, the warnings in #23 are not expected.

They look as if you had run update 6002 for the second time. Adding the column failed because it was already there, and adding the two indexes failed, too, because they were already there...

salvis’s picture

@wrender:

Well, seems you're satisfied with my analysis in #25.

Here's the last step: http://drupal.org/project/cvs/87985

I've changed the indexes so that they should be more useful for our queries that involve joins with the ACL tables. Please update to the Feb 16 -dev version and run update 6003.

I expect this to give you some improvement on your page load times over what you have now, but I don't know how much it will be. Obviously, I'd be thrilled if you can confirm that you see a noticeable difference...

mgifford’s picture

Ok, the CVS version of this no longer exists, but seems to be in the way back machine:
http://web.archive.org/web/20100712102734/http://drupal.org/project/cvs/...?

Has this made it into a stable release? 6.x-1.4 or 7.x-1.0? If not, maybe it's time for a new release.

I'm just looking into slow query logs and trying to track down issues.

salvis’s picture

Status: Active » Fixed

The commits are
http://drupalcode.org/project/acl.git/commit/d683e81e6d30be0d9112745af59...
and
http://drupalcode.org/project/acl.git/commit/93a0afd7212345267041e0ca909...

Yes, they are in the currently recommended releases.

wrender walked out on me, so let's close this.

salvis’s picture

BTW, you can browse the repository here on d.o or read the CHANGELOG.txt files, then I can spend my time for more productive/enjoyable things.

mgifford’s picture

Sorry, usually I assume it's committed when it's marked fixed, but won't necessarily check the CHANGELOG when it's still an open issue.

Thanks for committing this and also changing the status.

Status: Fixed » Closed (fixed)

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