Problem
A segment query fails instead of returning a user count, and the campaigns that use the segment fail along with it. Depending on where the query fails, you see one of the following:- A failure reason that names a length constraint, such as
'queryString' failed to satisfy constraint: Member must have length less than or equal to 262144. - A generic failure reason stating that an unexpected error occurred while executing the query, with no cause named.
- The segment stays in a running state and never returns a count.
Instructions
A segment definition is serialized into a single query before it runs, and that serialized query has a maximum length of 256 KB (262,144 characters). MoEngage evaluates the query as a whole, so the limit applies to the fully expanded definition — including the definitions of every custom segment referenced inside it, not just the conditions you see on screen. This is a separate limit from the nesting limit. A segment can be well within 6 levels of nesting and still exceed the query length, and a segment can exceed the nesting limit while being far shorter than 256 KB. Staying inside one limit does not keep you inside the other. Query length grows fastest in these patterns:- Many custom segments combined with OR. Each referenced custom segment expands into its own full definition inside the parent query.
- Custom segments used in the exclusion block. Excluded custom segments expand the same way as included ones, so an exclusion list of several custom segments adds as much length as an inclusion list of the same size.
- Filters with a large number of selected values. A single filter that matches hundreds of values — mobile numbers, product IDs, city names — can contribute more length than several ordinary conditions combined.
- Replace a list of OR’d custom segments with one segment. Where several custom segments differ only by the value of one attribute, rebuild them as a single segment with one filter matching all of those values. Ten segments that each match one language become one segment whose language filter lists ten values.
- Move long value lists into a file segment. Upload the identifiers as a file segment and reference that instead of listing the values in a filter. File segments are also not counted toward the nesting or custom segment limits.
- Flatten redundant references. Where a custom segment is referenced only to add one or two conditions, inline those conditions into the parent query and drop the reference.
- Split the segment and the campaign. Where the definition covers audiences that do not need to be evaluated together, create two or more segments and run a campaign for each.
Example
A segment is defined as ten custom segments combined with OR — one per preferred language, each already filtered to the same audience. The definition is within the limit of 10 custom segments per definition and is only 2 levels deep, but each of the ten references expands into its own full definition, so the serialized query exceeds 256 KB and fails with thelength less than or equal to 262144 error. Every recurring campaign that targets the segment fails with it.
Rebuilding the definition as a single segment — the shared audience filter AND preferred language is any of the ten values — replaces ten expanded definitions with one filter holding ten values. The query returns a count, and the campaigns resume.