Please refer to original issue and then Moshe's comment here.
http://groups.drupal.org/node/19185#comment-81786
Adding to issue queue so this can be tracked and verified to confirm it indeed helps performance.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | add_uid_index_to_og_uid-793588-4-D6.patch | 628 bytes | pdrake |
| #3 | 793588-og_uid-add-index-3.patch | 846 bytes | msonnabaum |
Comments
Comment #1
amitaibuAs mentioned by Moshe, we'd like to see some benchmarks to support this change.
Comment #2
msonnabaum commentedI just had an issue with this where I had a view of users with a content profile relationship, so it was joining on both og_uid.uid and og_uid.nid:
Adding an index on og_uid.uid made the query execution time go from 20s to 170ms. Quite an improvement.
Here are the before and after EXPLAINs:
Comment #3
msonnabaum commentedAnd here's a patch.
Comment #4
pdrake commentedI also ran into a basic view which needs this index. This query is from a view of groups in which a user is active. Below are profiles of the query before and after.
| 1 | 0.34071700 | SELECT sql_no_cache n.title, n.TYPE, n.status FROM og_uid ou INNER JOIN node n ON ou.nid = n.nid WHERE ou.uid = ? AND ou.is_active >= 1 AND n.TYPE in('group') ORDER BY n.title
| 2 | 0.03641400 | SELECT sql_no_cache n.title, n.TYPE, n.status FROM og_uid ou INNER JOIN node n ON ou.nid = n.nid WHERE ou.uid = ? AND ou.is_active >= 1 AND n.TYPE in('group') ORDER BY n.title
This is the same as the above patch, but re-rolled against the latest 6.x-2.x and using db_add_index instead of SQL. Given that I changed this patch slightly, feel free to reset my RTBC back to needs review if necessary. Not sure what the proper status would be here.
Comment #5
Grayside commentedDon't have time to think about this right now, but tagging for easy retrieval later.
Comment #6
Grayside commentedhttp://drupalcode.org/project/og.git/commit/2326de0