Professional Documents
Culture Documents
Optimization
Types of indexes.
A radix index is a multilevel, hybrid tree structure that allows a large number of key values to be stored efficiently
while minimizing access times. A key compression algorithm assists in this process. The lowest level of the tree
contains the leaf nodes, which contain the address of the rows in the base table that are associated with the key
value. The key value is used to quickly navigator to the leaf node with a few simple binary search tests.
The binary radix tree structure is very good for finding a small number of rows because it is able to find a given
row with a minimal amount of processing. For example, using a binary radix index over a customer number column
for a typical OLTP request like "find the outstanding orders for a single customer: will result in fast performance. An
index created over the customer number column is considered to be the perfect index for this type of query
because it allows the database to zero in on the rows it needs and perform a minimal number of I/Os.
Encoded Vector Index (EVI) An encoded vector index is a permanent object that provides access to a table by
assigning codes to distinct key values and then representing those values in a vector.The size of the vector will
match the number of rows in the underlying table.
Each vector entry represents the table row number in the same position. The codes generated to represent the
distinct key values can be 1, 2 or 4 bytes in length, depending upon the number of distinct values that need to be
represented. Because of their compact size and relative simplicity, the EVI can be used to process large amounts of
data very efficiently.
Even though an encoded vector index is used to represent the values stored in a table, the index itself cannot be
used to directly gain access to the table. Instead, the encoded vector index can only be used to generate either a
temporary row number list or a temporary row number bitmap. These temporary objects can then be used in
conjunction with a Table Probe to specify the rows in the table that the query needs to process. The main
difference with the Table Probe associated with an encoded vector index (versus a radix index) is that the paging
associated with the table can be asynchronous. The I/O can now be scheduled more efficiently to take advantage
of groups of selected rows. Large portions of the table can be skipped over where no rows are selected.
SELECT distinct
c.Exenme,d.cscnme,b.cmktid,b.mktdsc,b.cchnid,b.chndsc,b.ctype,
b.ctdsc,a.cmstor,a.ccust,a.cnme,a.cste,G.sspplc,G.sssys,
coalesce(G.ssefto,'0001-01-01') as effto,f.smid,f.smdesc,f.smftg
FROM RCMJ001 A {Rcm join to RCEP001)
JOIN SMART01/H_CUS00004 B ON A.CTYPE = B.CTYPE
JOIN SMART01/H_STA00003 C ON A.csal = c.accexe
join smart01/h_cus00011 d on a.cmcsc = d.cscid
join rssp001 G on a.cmstor = G.ssstor
join ismp001 f on G.sspplc = f.smplcd and G.sssys = f.smsys
WHERE a.CMSTTS= 0 and G.sspplc = 'EVDCTR' and
YEAR(ssefto) = 9999
and f.smid = 'SM' and f.smftg >= 2;
example 2:
SELECT distinct
c.Exenme,d.cscnme,b.cmktid,b.mktdsc,b.cchnid,b.chndsc,b.ctype,
b.ctdsc,h.cmstor,a.ccust,a.cnme,a.cste,G.sspplc,G.sssys,
coalesce(G.ssefto,'0001-01-01') as effto,f.smid,f.smdesc,f.smftg
FROM RCM A join rcep001 h on ccust = cmcust
JOIN SMART01/H_CUS00004 B ON A.CTYPE = B.CTYPE
JOIN SMART01/H_STA00003 C ON A.csal = c.accexe
join smart01/h_cus00011 d on H.cmcsc = d.cscid
join rssp001 G on h.cmstor = G.ssstor
join ismp001 f on G.sspplc = f.smplcd and G.sssys = f.smsys
WHERE H.CMSTTS= 0 and G.sspplc = 'EVDCTR' and
YEAR(ssefto) = 9999 and A.cmid = 'CM'
and f.smid = 'SM' and f.smftg >= 2;