This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
admin:features:rollups:indexing [2011/01/10 22:43] els created |
admin:features:rollups:indexing [2013/02/21 19:45] doc |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~NOTOC~~ | ||
+ | |||
{{page>:top_add&nofooter&noeditbtn}} | {{page>:top_add&nofooter&noeditbtn}} | ||
Line 5: | Line 7: | ||
===== Rollup Tables ===== | ===== Rollup Tables ===== | ||
- | [[admin:features:rollups:home|Overview]] -> [[admin:features:rollups:design|Design]] -> [[admin:features:rollups:create|Creation]] -> **[[admin:features:rollups:indexing|Indexing]]** -> [[admin:features:rollups:optimization|Optimization]] | + | [[admin:features:rollups:home|Overview]] | [[admin:features:rollups:design|Design]] | [[admin:features:rollups:create|Creation]] | **[[admin:features:rollups:indexing|Indexing]]** | [[admin:features:rollups:optimization|Optimization]] |
---- | ---- | ||
Line 12: | Line 14: | ||
- | Once the rollup tables have been created and declared, they may be indexed using Omnidex indexing. There are no restrictions on indexing of rollup tables, and rollup tables can be indexed just like any other table. Typically, they would be installed with both Omnidex MDK and Aggregation indexes. | + | Once the rollup tables have been created and declared, they may be indexed using Omnidex indexing. There are no restrictions on indexing of rollup tables, and rollup tables can be indexed just like any other table. |
Since rollup tables are often quite small, it is common to heavily index the rollup table. Ultimately, it is only necessary to index the rollup table in such a way that all queries that are redirected to the rollup table are fully optimized. This can be determined by reviewing the query plan for each query that is redirected to the rollup table. This is discussed in more detail later in this document. | Since rollup tables are often quite small, it is common to heavily index the rollup table. Ultimately, it is only necessary to index the rollup table in such a way that all queries that are redirected to the rollup table are fully optimized. This can be determined by reviewing the query plan for each query that is redirected to the rollup table. This is discussed in more detail later in this document. | ||
+ | The following example shows indexing for the tables that were created in the previous page. | ||
+ | |||
+ | <code> | ||
+ | create table "INDIVIDUALS" | ||
+ | physical "dat/individuals.dat" | ||
+ | ( | ||
+ | "INDIVIDUAL" CHARACTER(12) omnidex, | ||
+ | "HOUSEHOLD" CHARACTER(12) omnidex, | ||
+ | "NAME" CHARACTER(50) quicktext, | ||
+ | "GENDER" CHARACTER(1) omnidex bitmap, | ||
+ | "BIRTHDATE" ANSI DATE omnidex, | ||
+ | "PHONE" CHARACTER(14) omnidex, | ||
+ | "EMAIL" CHARACTER(60) quicktext, | ||
+ | constraint INDIVIDUALS_INDIVIDUAL_PK primary ("INDIVIDUAL"), | ||
+ | constraint INDIVIDUALS_HOUSEHOLD_FK foreign ("HOUSEHOLD") references "HOUSEHOLDS", | ||
+ | constraint INDIVIDUALS_GENDER_FK foreign ("GENDER") references "GENDERS", | ||
+ | ) | ||
+ | in "simple.xml"; | ||
+ | |||
+ | create table "INDIVIDUALS_BY_HOUSEHOLD" | ||
+ | physical "dat/individuals_by_household.dat" | ||
+ | ( | ||
+ | "HOUSEHOLD" CHARACTER(12) omnidex, | ||
+ | "GENDER" CHARACTER(1) omnidex bitmap, | ||
+ | "BIRTHDATE" ANSI DATE omnidex, | ||
+ | "NUM_INDIVIDUALS" UNSIGNED INTEGER, | ||
+ | constraint INDIVIDUALS_HOUSEHOLD_FK foreign ("HOUSEHOLD") references "HOUSEHOLDS", | ||
+ | constraint INDIVIDUALS_GENDER_FK foreign ("GENDER") references "GENDERS", | ||
+ | ) | ||
+ | as "select HOUSEHOLD, | ||
+ | GENDER, | ||
+ | BIRTHDATE, | ||
+ | count(*) NUM_INDIVIDUALS | ||
+ | from INDIVIDUALS | ||
+ | group by HOUSEHOLD, | ||
+ | GENDER, | ||
+ | BIRTHDATE" | ||
+ | in "simple.xml"; | ||
+ | |||
+ | |||
+ | create table "INDIVIDUALS_BY_DEMO" | ||
+ | physical "dat/individuals_by_demo.dat" | ||
+ | ( | ||
+ | "GENDER" CHARACTER(1) omnidex bitmap, | ||
+ | "BIRTHDATE" ANSI DATE omnidex, | ||
+ | "NUM_INDIVIDUALS" UNSIGNED INTEGER, | ||
+ | constraint INDIVIDUALS_GENDER_FK foreign ("GENDER") references "GENDERS", | ||
+ | ) | ||
+ | as "select GENDER, | ||
+ | BIRTHDATE, | ||
+ | count(*) NUM_INDIVIDUALS | ||
+ | from INDIVIDUALS | ||
+ | group by GENDER, | ||
+ | BIRTHDATE" | ||
+ | in "simple.xml"; | ||
+ | </code> | ||
+ | |||
+ | Indexes on rollup tables are automatically updated when the UPDATE INDEXES statement is issued: | ||
+ | |||
+ | <code> | ||
+ | > update indexes | ||
+ | Database | ||
+ | Table Rows CPU Elapsed | ||
+ | ---------------------------------------------------------------------------- | ||
+ | SIMPLE | ||
+ | COUNTRIES 239 0:00 0:00 | ||
+ | STATES 76 0:00 0:00 | ||
+ | GENDERS 2 0:00 0:00 | ||
+ | HOUSEHOLDS 1,909 0:00 0:00 | ||
+ | INDIVIDUALS 5,000 0:00 0:00 | ||
+ | INDIVIDUALS_BY_HOUSEHOLD 5,000 0:00 0:00 | ||
+ | INDIVIDUALS_BY_DEMO 4,793 0:00 0:00 | ||
+ | ---------------------------------------------------------------------------- | ||
+ | Total 0:01 0:03 | ||
+ | |||
+ | Omnidex indexes updated | ||
+ | > | ||
+ | </code> | ||
==== ==== | ==== ==== | ||
**[[admin:features:rollups:create|Prev]]** | **[[admin:features:rollups:optimization|Next]]** | **[[admin:features:rollups:create|Prev]]** | **[[admin:features:rollups:optimization|Next]]** | ||
+ | |||
====== Additional Resources ====== | ====== Additional Resources ====== |