Subject Puzzling plan (or lack of)
Author Rick Debay
I have four tables that share a common generator for their ID.
I also have a check constraint to make sure that an ID is never set that
is already in use.
The puzzling thing is that the plan makes no use of indexes (ID is the
PK for each table).

ALTER TABLE INVC_WHLSLR_INVC ADD CONSTRAINT C_WHSLEINV_ID CHECK (
/* ID is NULL, so generator will assign it */
NEW.ID IS NULL OR
(
/* make sure ID isn't in use by another table */
SELECT FIRST 1
1
FROM
INVC_GRANTEE_INVC g,
INVC_RXS_INVC r,
INVC_PHARM_BILLGRP_INVC b
WHERE
g.ID = NEW.ID OR
r.ID = NEW.ID OR
b.ID = NEW.ID
) IS NULL );

PLAN JOIN (R NATURAL,G NATURAL,B NATURAL)