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.

CommentFileSizeAuthor
commons_views_argument_issue.png63.58 KBmsonnabaum

Comments

ezra-g’s picture

Issue tags: +Performance

Thanks! Adding the 'performance' tag.

ezra-g’s picture

Priority: Normal » Major
ezra-g’s picture

I'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().

ezra-g’s picture

Version: » 7.x-3.x-dev
BarisW’s picture