Currently, commons_follow_plugin_argument_default_message calls commons_follow_get_followed_message_ids, which returns all the nids for things you are following. This can be a huge number of results, and it takes a while to process them.
While profiling a site with fake content, commons_follow_plugin_argument_default_message returned 3515 results, which then got passed to views_handler_argument_node_nid::title_query, where it loops through the PDO object (see xhprof screenshot below).

That's pretty wasteful considering I was just loading the front page view which only shows me the top 4 items I'm following.
To make this more scalable, we need to be able to sort and limit the nids returned by timestamp. This is difficult to implement with the current design, since hook_commons_follow_get_nids() expects nids back from multiple sources.
Since they are all querying against flag_content, maybe they could return db_or() objects, and then commons_follow_get_followed_message_ids() could perform a db_select, joined against node, sorted on node.changed, and limited to the number of records the view needs.
| Comment | File | Size | Author |
|---|---|---|---|
| commons_views_argument_issue.png | 63.58 KB | msonnabaum |
Comments
Comment #1
ezra-g commentedThanks! Adding the 'performance' tag.
Comment #2
ezra-g commentedComment #3
ezra-g commentedI've started this work in a feature branch: http://drupalcode.org/project/commons_follow.git/commit/b230a17
The next step is to pass the sort and limit options from the View to commons_follow_get_nids().
Comment #4
ezra-g commentedI marked #2047431: Homepage for admin isn't load for large data as a duplicate.
Comment #5
BarisW commentedProbably related: #1884772: Segfault with large number of arguments in views_break_phrase()