Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
admin:indexing:basicstrategies:joins [2011/01/13 23:34]
els
— (current)
Line 1: Line 1:
-{{page>:​top_add&​nofooter&​noeditbtn}} 
  
-====== Administration:​ Indexing Strategies ====== 
- 
-===== Basic Strategies ===== 
- 
-[[admin:​indexing:​basicstrategies:​home|Overview]] |  
-[[admin:​indexing:​basicstrategies:​criteria|Criteria]] |  
-[[admin:​indexing:​basicstrategies:​joins|Table Joins]] |  
-[[admin:​indexing:​basicstrategies:​aggregations|Aggregations]] |  
-[[admin:​indexing:​basicstrategies:​orderby|Order By's]] 
- 
----- 
- 
-==== Optimizing Table Joins ==== 
- 
-Tables joins are usually optimized by creating indexes on the table constraints. ​ For relational databases, it is only necessary to index the foreign keys since the relational database'​s indexes on the primary keys will suffice. ​ For raw data files, both the primary and foreign keys should be indexed. 
- 
-Multi-column constraints should be indexed using multi-column Omnidex indexes. ​ These are custom indexes that combine multiple columns into an index. ​ The order of the columns in the indexes should match the order of the columns in the constraint. 
- 
-Not all joins follow actual constraints. ​ Sometimes there is a parent-child relationship between tables but no formal constraint is declared. ​ In these cases, create Omnidex indexes as though a constraint was declared. ​ 
- 
-The following examples show how to evaluate queries and choose the Omnidex indexes. ​ Below the examples is an Omnidex Environment File that will generate these indexes. 
- 
-== Example 1.  Table joins on primary and foreign constraints == 
- 
-In this example, the HOUSEHOLD column is a primary constraint in HOUSEHOLDS and a foreign constraint in INDIVIDUALS. 
- 
-  select ​    ​I.NAME,​ H.ADDRESS, H.CITY, H.STATE, H.ZIP, I.PHONE 
-    from     ​INDIVIDUALS I join HOUSEHOLDS H on I.HOUSEHOLD = H.HOUSEHOLD 
-   ​where ​    ​H.STATE = '​CO'​ and I.NAME = '​John' ​ 
- 
-For relational databases, the HOUSEHOLD column in INDIVIDUALS should be an Omnidex index since it is a foreign key.  For raw data files, the HOUSEHOLD column in HOUSEHOLDS should also be an Omnidex index since it is a primary key. 
- 
-== Example 2.  Table joins along multi-column constraints == 
- 
-In this example, the HOUSEHOLD column is a primary constraint in HOUSEHOLDS and a foreign constraint in INDIVIDUALS. 
- 
-  select ​    ​HOUSEHOLDS.NAME,​ COUNTIES.COUNTY 
-    from     ​HOUSEHOLDS join COUNTIES on HOUSEHOLDS.STATE = COUNTIES.STATE and 
-                                         ​HOUSEHOLDS.COUNTY_CODE = COUNTIES.COUNTY_CODE ​ 
- 
-For relational databases, the STATE and COUNTY_CODE columns of HOUSEHOLD should be indexed using a multi-column Omnidex index. ​ For raw data files, the STATE and COUNTY_CODE columns of COUNTIES should also be a multi-column Omnidex index. 
- 
- 
-=====  ===== 
- 
-**[[prev|Prev]]** | **[[next|Next]]** 
- 
-====== Additional Resources ====== 
- 
-See also:  
- 
-{{page>:​admin:​indexing:​see_also&​nofooter&​noeditbtn}} 
- 
-{{page>:​bottom_add&​nofooter&​noeditbtn}} 
 
Back to top
admin/indexing/basicstrategies/joins.1294961698.txt.gz ยท Last modified: 2012/10/26 14:52 (external edit)