What is meant by Primary Index and Secondary Index
Explain the what is primary and secondary index.
When you activate an object say ODS / DSO, the system automatically generate an index based on the key fields and this is primary index.
In addition if you wish to create more indexes , then they are called secondary indexes.
The primary index is distinguished from the secondary indexes of a table. The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.
You can also create further indexes on a table. These are called secondary indexes. This is necessary if the table is frequently accessed in a way that does not take advantage of the sorting of the primary index for the access. Different indexes on the same table are distinguished with a three-place index identifier.
Lets say you have an ODS and the Primary Key is defined as Document Nbr, Cal_day. These two fields insure that the records are unqiue, but lets lay you frequently want to run queries where you selct data based on the Bus Area and Document Type. In this case, we could create a secondary index on Bus Area, Doc Type. Then when the query runs, instead of having to read every record, it can use the index to select records that contain just the Bus Area and Doc type values you are looking for.
Just because you have a secondary index however, does not mean it will be used or should be used. This gets into the cardinality of the fields you are thinking about indexing. For most DBs, an index must be fairly selective to be of any value. That is, given the values you provide in a query for Bus Area and Doc Type, if it will retrieve a very small percentage of the rows form the table, the DB probably should use the index, but if the it would result in retrieving say 40% of the rows, it si almost always better to just read the entire table.
Having current DB statististics and possibly histograms can be very important as well. The DB statistics hold information on how many distinct values a field has, e.g. how many distinct values of Business Area are there, how many doc types.
Secondary indexes are usally added to ODS (which you can add using Admin Wkbench) based on your most frequently used queries. Secondary indexes might also be added to selected Dimension and Master data tables as well, but that usually requires a DBA, or someone with similar privileges to create in BW.
相關文章
- Examples of Secondary IndexIndex
- unique index與primary key的區別Index
- Secondary Indexes on Index-Organized Tables (231)IndexZed
- What are general rules when deciding on index?Index
- mysql中key 、primary key 、unique key 與index區別MySqlIndex
- What is the difference between Mysql InnoDB B+ tree index and hash index? Why does MongoDB use B-tree?MySqlIndexMongoDB
- ORA-02429: cannot drop index used for enforcement of unique/primary keyIndex
- KEEP INDEX | DROP INDEXIndex
- rowid,index,INDEX FULL SCAN,INDEX FAST FULL SCAN|IndexAST
- OGG How to handle / replicate tables with no (without) primary key (PK) or unique index (UI) (UPI) [IndexUI
- INDEX UNIQUE SCAN,INDEX FULL SCAN和INDEX FAST FULL SCANIndexAST
- Clustered Index Scan and Clustered Index SeekIndex
- oracle hint之full,index,index_asc,index_desc,index_combile示例OracleIndex
- IndexIndex
- Index的掃描方式:index full scan/index fast full scanIndexAST
- rebuild index 和 recreate index (重新建立index) 的區別RebuildIndex
- pk 、unique index 和 index 區別Index
- global index & local index的區別Index
- alter index rebuild與index_statsIndexRebuild
- [20180608]Wrong Results with IOT, Added Column and Secondary Index.txtIndex
- B-index、bitmap-index、text-index使用場景詳解Index
- Index Full Scan vs Index Fast Full ScanIndexAST
- Using index condition Using indexIndex
- 【Oracle】global index & local index的區別OracleIndex
- Index Full Scans和Index Fast Full ScansIndexAST
- Index Full Scan 與 Index Fast Full ScanIndexAST
- PostgreSQL:INDEXSQLIndex
- <MYSQL Index>MySqlIndex
- jQuery index()jQueryIndex
- index索引Index索引
- rebuild indexRebuildIndex
- index rebuildIndexRebuild
- Bitmap IndexIndex
- index range scan,index fast full scan,index skip scan發生的條件IndexAST
- [20180609]Wrong Results with IOT, Added Column and Secondary Index2.txtIndex
- create index/create index online區別Index
- Create index with open on-line index creationIndex
- MYSQL中的type:index 和 Extra:Using indexMySqlIndex