Maybe it's an exaggeration, but I have now example of 7 times better perfomance and I need a little bit more of explanations to fully understand when and if only on FB 3.0.
Why is it adviced to use HASH JOIN on FB 3.0? I just checked that using this trick on FB 2.5 makes almost the same profit. I don't see HASH JOIN in the plan, but the difference in indexed reads is very similar when seeing HASH JOIN on FB 3.0.
Normal plan on FB 2.5 vs adding +0 to both columns of a join - second one resulting in 7 times better performance.
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN JOIN (JOIN (MERGE (SORT (JOIN (N INDEX (MK_NAGL_KLU_STATUS), NA INDEX (PK_NAGLAKT), KN INDEX (RDB$PRIMARY91), K INDEX (RDB$PRIMARY91), NZR INDEX (FK_NAGLZR_NAGL), NZW INDEX (RDB$FOREIGN1005), PZR INDEX (FK_POZZR_NAGLZR, FK_POZZR_KARTOTEKA), PZW INDEX (RDB$PRIMARY979))), SORT (U NATURAL)), AKW INDEX (RDB$PRIMARY18)), ND INDEX (PK_NAGLDOST))
PLAN JOIN (JOIN (JOIN (JOIN (N INDEX (MK_NAGL_KLU_STATUS), U INDEX (RDB$PRIMARY122), NA INDEX (PK_NAGLAKT), NZR INDEX (FK_NAGLZR_NAGL), NZW INDEX (RDB$FOREIGN1005), PZR INDEX (FK_POZZR_NAGLZR, FK_POZZR_KARTOTEKA), PZW INDEX (RDB$PRIMARY979)), J INDEX (RDB$PRIMARY116)), AKW INDEX (RDB$PRIMARY18)), ND INDEX (PK_NAGLDOST))
Adapted Plan
--------------------------------------------------------------------------------
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN JOIN (JOIN (MERGE (SORT (JOIN (N INDEX (MK_NAGL_KLU_STATUS), NA INDEX (PK_NAGLAKT), KN INDEX (PK_KONTRAH), K INDEX (PK_KONTRAH), NZR INDEX (FK_NAGLZR_NAGL), NZW INDEX (FK_NAGLZAMWSP_NAGL), PZR INDEX (FK_POZZR_NAGLZR, FK_POZZR_KARTOTEKA), PZW INDEX (PK_POZZAMWSP))), SORT (U NATURAL)), AKW INDEX (PK_AKWIZYTOR)), ND INDEX (PK_NAGLDOST))
PLAN JOIN (JOIN (JOIN (JOIN (N INDEX (MK_NAGL_KLU_STATUS), U INDEX (PK_UZYTKOWNIK), NA INDEX (PK_NAGLAKT), NZR INDEX (FK_NAGLZR_NAGL), NZW INDEX (FK_NAGLZAMWSP_NAGL), PZR INDEX (FK_POZZR_NAGLZR, FK_POZZR_KARTOTEKA), PZW INDEX (PK_POZZAMWSP)), J INDEX (PK_JEDNORG)), AKW INDEX (PK_AKWIZYTOR)), ND INDEX (PK_NAGLDOST))
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN JOIN (JOIN (MERGE (SORT (JOIN (PZR INDEX (FK_POZZR_KARTOTEKA), NZR INDEX (PK_NAGLZR), PZW INDEX (RDB$PRIMARY979))), SORT (MERGE (SORT (JOIN (N INDEX (MK_NAGL_KLU_STATUS), NA INDEX (PK_NAGLAKT), KN INDEX (RDB$PRIMARY91), K INDEX (RDB$PRIMARY91), NZW INDEX (RDB$FOREIGN1005))), SORT (U NATURAL)))), AKW INDEX (RDB$PRIMARY18)), ND INDEX (PK_NAGLDOST))
PLAN JOIN (JOIN (JOIN (MERGE (SORT (MERGE (SORT (JOIN (PZR INDEX (FK_POZZR_KARTOTEKA), NZR INDEX (PK_NAGLZR), PZW INDEX (RDB$PRIMARY979))), SORT (JOIN (N INDEX (MK_NAGL_KLU_STATUS), NA INDEX (PK_NAGLAKT), NZW INDEX (RDB$FOREIGN1005))))), SORT (U NATURAL)), J INDEX (RDB$PRIMARY116)), AKW INDEX (RDB$PRIMARY18)), ND INDEX (PK_NAGLDOST))
Adapted Plan
--------------------------------------------------------------------------------
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN (R INDEX (FK_REZ_POZZR))
PLAN JOIN (JOIN (MERGE (SORT (JOIN (PZR INDEX (FK_POZZR_KARTOTEKA), NZR INDEX (PK_NAGLZR), PZW INDEX (PK_POZZAMWSP))), SORT (MERGE (SORT (JOIN (N INDEX (MK_NAGL_KLU_STATUS), NA INDEX (PK_NAGLAKT), KN INDEX (PK_KONTRAH), K INDEX (PK_KONTRAH), NZW INDEX (FK_NAGLZAMWSP_NAGL))), SORT (U NATURAL)))), AKW INDEX (PK_AKWIZYTOR)), ND INDEX (PK_NAGLDOST))
PLAN JOIN (JOIN (JOIN (MERGE (SORT (MERGE (SORT (JOIN (PZR INDEX (FK_POZZR_KARTOTEKA), NZR INDEX (PK_NAGLZR), PZW INDEX (PK_POZZAMWSP))), SORT (JOIN (N INDEX (MK_NAGL_KLU_STATUS), NA INDEX (PK_NAGLAKT), NZW INDEX (FK_NAGLZAMWSP_NAGL))))), SORT (U NATURAL)), J INDEX (PK_JEDNORG)), AKW INDEX (PK_AKWIZYTOR)), ND INDEX (PK_NAGLDOST))