phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\EagerRowLimitExceeded

Eager loading ' ' returned rows which exceeds the limit of

Error message

Eager loading '{modelName}' returned {rowCount} rows which exceeds the limit of {limit}

What it means

Thrown after an eager-loading batch query is materialized: the number of rows fetched at this level exceeds Loader::MAX_ROWS_PER_LEVEL, a hard safety cap preventing unbounded memory use when an eager path fans out over too many parents.

Solutions

  1. Narrow the parent query (where/limit) so fewer rows are eager-loaded at once
  2. Load the relation lazily instead of eagerly if the result set is legitimately large
  3. Split the eager load into smaller batches of parents
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at phalcon/Mvc/Model/Eager/Loader.zep:613 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/d6892a76d7d28d5a. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Model/Eager/Loader.zep:613

            let columnList = str_replace(" ", "", columnList);

            for referencedField in referencedFields {
                if unlikely false === strpos(columnList, referencedField) {
                    throw new MissingEagerKeyColumn(alias, referencedField);
                }
            }
        }

        let resultset = call_user_func_array(
            [modelInstance, "find"],
            [findParams]
        );

        resultset->materialize();

        if unlikely resultset->count() > self::MAX_ROWS_PER_LEVEL {
            throw new EagerRowLimitExceeded(
                referencedModel,
                resultset->count(),
                self::MAX_ROWS_PER_LEVEL
            );
        }

        return resultset;
    }

    /**
     * Relation fields are declared as a string for a single column and an
     * array for a composite key. Normalizing removes that fork everywhere
     * downstream.
     */
    protected function normalizeFields(var fields) -> array
    {
        if typeof fields === "array" {
            return fields;

View on GitHub (pinned to b7419de9cd)