Skip to content

⚡ Performance: Missing memoization in StoreManager and plugin overhead in Store module #40706

Description

@lbajsarowicz

Performance Issues in Magento_Store

Findings

# File Line(s) Issue Consensus Severity
32 Model/StoreManager.php 141 Missing Caching: hasSingleStore() loads full store collection on every call. Code has TODO: MAGETWO-39902 add cache. Medium-High
33 Model/StoreManager.php 179-192 N+1 Loading: getStores() calls storeRepository->getList() and post-filters in PHP loop instead of query-level filtering. Medium-High
34 Model/StoreManager.php 218-231 N+1 Loading: getWebsites() same pattern as #33 — calls websiteRepository->getList() and filters in PHP. Medium-High
36 App/Action/Plugin/Context.php 148 Plugin Overhead: getDefaultStoreView() called on EVERY frontend request via beforeDispatch() plugin without caching. Medium-High

Review Note — Finding #36 (Context plugin getDefaultStoreView caching)

After code review, this specific optimization was rejected: Context::beforeDispatch() is called exactly once per HTTP request — there is no loop or repeated invocation. Caching getDefaultStoreView() inside this plugin provides zero performance benefit under normal operation. Additionally, getDefaultStoreView() can return null, and the null-safe memoization pattern would require a sentinel flag, adding complexity for no gain.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions