This is an issue thread for the D7 version of same change found on http://drupal.org/node/1213154.

Front page SQL tests show that the _homebox_can_view_block() function is getting called multiple times per HTTP request.

Comments

Matt-H’s picture

Status: Active » Patch (to be ported)
StatusFileSize
new1.97 KB

This patch improves performance by setting a static variable and caching the query results.

roderik’s picture

Title: Cache query results to improve performance (D7 version) » Cache query results in _homebox_can_view_block() (D7 version)
Version: 7.x-2.0-beta6 » 7.x-2.x-dev
Status: Patch (to be ported) » Needs review
StatusFileSize
new1.73 KB

1) if _homebox_can_view_block() is called multiple times per HTTP request with different arguments every time (i.e. module+delta), then this still doesn't make a difference, because database queries are still being made for every call.

2) Why cache_get() being used here, in addition to the static variable? It's caching the small result of one small SQL query. It doesn't seem to me like the cache_get() is necessarily faster then the query itself - so that would just adds code bloat without speedup.

Attached patch caches all roles at once, so makes only one SQL query (even though that one query may take a little longer). I think this one makes more sense.

  • drumm committed f139648 on 7.x-2.x authored by roderik
    Issue #1372406 by roderik: Cache query results in...
drumm’s picture

Issue summary: View changes
Status: Needs review » Fixed

Looks good, committed.

Status: Fixed » Closed (fixed)

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