Informix Error -395: The where clause contains an outer cartesian product.
Cause and resolution
The where clause contains an outer cartesian product.
This query requests an outer join, but either the WHERE clause is missing in the query, or the conditions in the WHERE clause cause every row of the subordinate table to be selected for every row of the dominant table, resulting in a very large output.
Review the query, and check that at least one condition in the WHERE clause relates each dominant-subordinate pair of tables in the query.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-395 is another guardrail on Informix's older OUTER-clause join syntax, closely related to
-393: this one fires when a dominant/subordinate table pair in an outer join has no WHERE
clause condition relating them at all, which would produce every row of the subordinate table
matched against every row of the dominant table — an unintended and typically enormous cartesian
product.
- A missing join condition between the dominant table and an
OUTERsubordinate table — the direct cause, usually from an accidentally omitted or deletedWHEREcondition. - A
WHEREclause condition mistakenly relating the wrong pair of tables, leaving the actual dominant-subordinate pair with no connecting condition. - A query built up incrementally, where a table was added to the
FROMclause but its corresponding join condition was never added toWHERE.
Solutions / Resolution
- Review the query to ensure every dominant-subordinate table pair has at least one connecting
condition in the
WHEREclause, per the official guidance. - When adding a new
OUTERtable to a query, add its join condition toWHEREin the same change, rather than as an afterthought. - Consider migrating to ANSI-SQL outer join syntax (
LEFT OUTER JOIN ... ON ...), which makes the connection between each pair of tables explicit and much harder to accidentally omit.
Examples
A missing join condition
SELECT c.name, o.order_id
FROM customers c, OUTER orders o
WHERE c.region = 'West';
-- -395: no condition relates customers to orders at all
Fix — add the missing join condition:
SELECT c.name, o.order_id
FROM customers c, OUTER orders o
WHERE c.region = 'West' AND c.customer_id = o.customer_id;
Using ANSI syntax to make the connection explicit
SELECT c.name, o.order_id
FROM customers c LEFT OUTER JOIN orders o ON c.customer_id = o.customer_id
WHERE c.region = 'West';
Diagnostic Checks
- Identify every dominant-subordinate table pair in the
FROMclause. - Confirm each pair has at least one connecting condition in the
WHEREclause. - Consider migrating to ANSI outer join syntax to make missing connections far more visible at a glance.
Related Errors / Related Topics
- -393 — "A condition in the where clause results in a two-sided outer join." The closely
related sibling restriction on the same older
OUTER-clause syntax — both concern howWHEREclause conditions must correctly relate dominant and subordinate tables.
An outer join always needs an explicit connecting condition for every dominant-subordinate pair —
migrating to ANSI LEFT OUTER JOIN ... ON ... syntax makes this much harder to accidentally omit.