|Query optimization | Links ||
You can save time when linking two tables where a prelink exists because the <link> is already evaluated.
A prelink creates a vector of index values for each row in the base table that corresponds to the matching row in the foreign table.
Prelinks are useful when you link the same tables together often. It allows you to evaluate the <link> once, when the prelink is created, and then take advantage of the evaluation whenever you link those tables together.
You often link the Sales Detail table (pub.doc.retail.altseg.sales_detail_sku) to the Product Master table (pub.doc.retail.altseg.products) in order to gain more information on the products. Due to the size of your transaction table, these <link> operations can be expensive. In order to save time on future queries, you create a prelink from the Sales Detail to the Product Master.
<base table="pub.doc.retail.altseg.sales_detail_sku"/> <link table2="pub.doc.retail.altseg.products" col="sku" col2="sku" materialize="1"/>
Now there exists a file in the base table that holds information on the mapping between the two tables. Next time you link these two tables, the file is read to determine the match for each row instead of searching the foreign table for each match.