a given SQL statement that contains a join. This means that a record from the
first table is fetched before trying to fetch any records from the second table.
Generally other join algorithms like hash-joins, merge-joins, and others are also
considered. This keyword is frequently combined with the forceSelectOrderkeyword.
Review the previous example with the tables InventTrans and InventDim. You
could risk that the database finds all InventTrans records by the index ItemIdx
and all the InventDim records by the BatchId. (If you hint the index DimIdIdx
this will be used for this search.) The two collections of records are hashed
together. For the database to find the inventTrans and then the inventDim for
each inventTrans, specify forceNestedLoops, as shown in the following
example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | static void DemoForceSelectOrder() { InventTrans inventTrans; InventDim inventDim; while select forceSelectOrder forceNestedLoop inventTrans index hint ItemIdx where inventTrans.ItemId == 'X' join inventDim where inventDim.inventDimId ==inventTrans.inventDimId&& inventDim.inventBatchId == 'Y' { } } |
Best Regards,
Hossein Karimi
No comments:
Post a Comment