Subject Plan ignores PK and goes natural
Author Rick Debay
Firebird 2.0 chooses a plan with NATURAL in it, when there is a
perfectly good primary key available. Firebird 1.5 doesn't make this
mistake.

FB 2.0, not using primary key
PLAN JOIN (PO NATURAL, PB INDEX (FK_POBILL_PURCHORDER), PBI INDEX
(FK_POBILLITM_POBILL), D INDEX (PK_MDDB_DRUG))

FB 1.5, using primary key
PLAN JOIN (D INDEX (I_MDDBDRUG_GPI),PBI INDEX (U_RPL_POBILL_ITM),PB
INDEX (PK_RPL_POBILL),PO INDEX (PK_RPL_PO))

SELECT
pbi.ID, pbi.QTY
FROM
RPL_PO po
JOIN RPL_POBILL pb
ON pb.PO = po.ID
JOIN RPL_POBILL_ITM pbi
ON pbi.INVOICE = pb.ID
JOIN MDDB_DRUG d
ON d.PRODUCTID = pbi.NDC
WHERE
/* disable index under FB 2.0 */
po.REPLENISH_GRP || '' = '01E' AND
d.MULTISRC = 'Y' AND
d.GPI = '78512015000322' AND
d.TEE = 'NR' AND
d.UNIT_DOSE_USE = 'U' AND
(d.ATOM <> 'Y' OR d.PKG_SZ = 100)

Is there any way to force the use of the PK? I'd be willing to sanitize
the database and send it to a developer. It seems that 2.0 is making
bad choices compared to 1.5 for many of our queries.