Iq Effectily Soundry
Iq Effectily Soundry
Iq Effectily Soundry
Richard Soundy
Business Development EMEA
[email protected]
Sybase IQ
2 6
1 3 5 7
1 2 3 4 5 6 7 8
Leaf Level (Data)
Sybase IQ Indexes
• Indexes are the data (a data access method)
– no separate data store
• A column is likely to have multiple indexes
– always has at least one index
• Index selection for a column is based upon
– Number of discrete values (cardinality)
– Usage in queries
– To some extent, the column’s data type
Index Types -1
• Default Index (aka Fast Projection or FP)
– Raw data compressed on disk
– comes in 4 flavours
• Low Fast (LF)
– Bit map index
• High Non Group (HNG)
– Bit-wise index
• High Group (HG)
– G-Array (relative of a B-tree)
– Comes in 3 flavours
Index Types - 2
• Compare Index (CMP)
– Column Compare Index
• Word Index (WD)
– Sort of “Free Text” Index
• DATE
• TIME
• DTTM (date time index)
Default Index - FP
• Created automatically by Create Table
• Used for
– Ad-Hoc joins
– String searches
– Certain calculations
– Projection of data
• This index cannot be created or dropped
Disk Compression
• Current FP (default) index supports:
• Raw data values (compressed on disk)
• 1-byte lookup table compression for up to
255 distinct values (compressed on disk
and in memory)
• 2-byte lookup table compression for up to
65K distinct values (compressed on disk
and in memory)
• 3-byte lookup table compression for up to
16m distinct values (compressed on disk
and in memory)
Creating FP in IQ 15 (upgrade?)
• 3-byte with many distincts or wide
datatype requires large cache to
support
• Eligible existing columns can be
upgraded using a stored procedure
• This is sp_iqrebuildindex (as for the
older migration when FP(2) arrived)
Disk Compression – Managing FPs
• 16M (16,777,216) values is the upper limit
for distinct values in a column for the new
compression, but the practical limit will
usually be lower
• Options will allow users to tune memory
usage
• Supported for most data types
• except LOBs and columns less than 4
bytes wide
Distinct Count
IQ Fast Project Indexes
Column Data Column Data Column Data
Size = 1 byte Size = 2 bytes Size = 3 bytes
Column Data
Size > 3 bytes
<257 values PFP/Flat FP(1) FP(1) FP(1)
257-65,536 Not Possible PFP/Flat PFP/Flat FP(2)
65,537-16,777,216 Not Possible No Possible PFP/Flat FP(3)
>16,777,216 Not Possible Not Possible Not Possible FP(3)
128 MB 1,024 / 512 / 256 11,184,810 8,388,608 3,355,443 1,864,135 986,895 510,333
256 MB 2,048 / 1,024 / 512 16,777,216 16,777,216 7,610,886 3,728,270 1,973,790 1,020667
1-50,90,102-135,1090-4573,7833,
9011-11430,...
Bitmap Indexes
B itm ap In d ex fo r ST AT E
ro w-id
1
AK
0
AL
0
AR
0
CA
1
CO
0
DC
0
DE
0
FL
0
...
2 0 0 0 0 0 0 0 1
3 0 1 0 0 0 0 0 0
4 1 0 0 0 0 0 0 0
5 0 1 0 0 0 0 0 0
B-Tree
Index
a b c
1,2
a B(ptr) C=4
1,2
SELECT x, y, z FROM If a query has an ORDER BY clause, and the ORDER BY column list is a
prefix
t1 of a multicolumn index where all columns referenced in the SELECT list are
ORDER BY x, y present in a multicolumn index, then the multicolumn index performs vertical
projection
6 0 1 1 0 0 1 1 0
9 1 0 0 1 1 0 0 1
5 0 1 0 1 0 1 0 1
11 1 0 1 1 1 0 1 1
9 1 0 0 1 1 0 0 1
3 0 0 1 1 0 0 1 1
7 0 1 1 1 0 1 1 1
12 1 1 0 0 1 1 0 0
Data with large number of values stored in binary form
Data sliced vertically - each bit position can be manipulated separately
Many bit positions are either all on or all off so no storage space is required
with compression
Sales 8 bit 4 bit 2 bit 1 bit
DTTM
DATE
TIME
80 Novemb
Index Advice Usage
• Index Advice messages persist only in memory
– Number of messages retained is set by the database
option Index_Advisor_Max_Rows
– Index Advice messages may be cleared at anytime
using the reset flag (any nonzero number)
• Example: exec sp_indexadvice (1)
– Messages will also be lost when the IQ server is
shutdown
• You can create an event to capture the output to a
table
Workload Monitoring
– Workload Monitoring provides 7 system stored
procedures which allow the DBA to monitor
database object usage
• DBA can assess usage of tables, columns and indexes
• These are useful in decisions regarding dropping unused
indexes and objects occupying space in the database
– sp_iqtableuse
Column Usage
– sp_iqcolumnuse
Index Activity
– sp_iqindexuse
• NOpt = Number of Metadata/Uniqueness Accesses
• NQry = Number of Query Accesses
• NConstraint = Number of Accesses for Unique or RI
Checks
Monitoring Unused Objects
– sp_iqunusedtable()
• Returns table name and owner
– sp_iqunusedindex()
• Returns index name, table name, owner, index
type
– sp_iqunusedcolumn()
• Returns table name, column name, owner
Capturing Workload Monitoring
Statistics - 1
– Like the Index Advisor, you need to
capture the statistics periodically