|
|
列名 | 描述 |
SHOW_ID | 表外键,包含关于各演出清单的信息 |
CHANNEL_ID | 表外键,包含关于播放演出的每个频道的信息 |
STATION_ID | 表外键,包含和频道相关的每个电视台的信息 |
CITY_ID | 表外键,包含关于上演该演出的每个城市的信息 |
DAY | 演出播放的日期 |
TIME | 演出播放的当天的时间 |
<other columns> | 描述了演出清单的其他属性 |
P1: SHOW_ID = ? |
IX1 ON SHOW_LISTINGS(SHOW_ID, CHANNEL_ID, STATION_ID, TIME) |
IX4 ON SHOW_LISTINGS(CITY_ID, SHOW_ID, CHANNEL_ID, STATION_ID, TIME) |
IX5 ON SHOW_LISTINGS(SHOW_ID, STATION_ID, CITY_ID, CHANNEL_ID) |
列名 | 描述 |
SHOW_ID | 表外键,包含关于各演出清单的信息 |
CHANNEL_ID | 表外键,包含关于播放演出的每个频道的信息 |
STATION_ID | 表外键,包含和频道相关的每个电视台的信息 |
CITY_ID | 表外键,包含关于上演该演出的每个城市的信息 |
DAY | 播放演出的日期 |
TIME | 播放演出的时间 |
RATING | 在一天的某个时间,在特定城市中,某个电视台频道的演出清单的收视率 |
P1: SHOW_LISTINGS.SHOW_ID = RATINGS.SHOW_ID |
P1: T1.A = T2.A |
P4: T1.D = T2.D |
>>-RUNSTATS--ON TABLE--table name--+-USE PROFILE------------+---> |
Automatic runstats (AUTO_RUNSTATS)=ON |
RUNSTATS ON TABLE schema_name.SHOW_LISTINGS ON COLUMNS ((SHOW_ID, CHANNEL_ID, |
RUNSTATS ON TABLE schema_name.SHOW_LISTINGS ON COLUMNS ((SHOW_ID, CHANNEL_ID, |
RUNSTATS ON TABLE schema_name.SHOW_LISTINGS ON ALL COLUMNS AND ON COLUMNS |
RUNSTATS ON TABLE schema_name.SHOW_LISTINGS ON COLUMNS ((SHOW_ID, |
Informational tokens are "DB2 v8.1.1.120", "s060801", "U808888", and FixPak "13". |
RUNSTATS ON TABLE SCHEMA_NAME.EMPLOYEE WITH DISTRIBUTION; |
SELECT EMPNO, FIRSTNME, LASTNAME, WORKDEPT, SEX, JOB, SALARY |
EMPNO FIRSTNME LASTNAME WORKDEPT SEX JOB SALARY |
db2 -tvf $DB2PATH/misc/EXPLAIN.DDL |
SET CURRENT EXPLAIN MODE EXPLAIN; |
db2exfmt -d <DBNAME> -1 -g -o <FILENAME> |
2 |
SELECT EMPNO, FIRSTNME, LASTNAME, WORKDEPT, SEX, JOB, SALARY |
0.0761719 |
RUNSTATS ON TABLE <SCHEMA_NAME>.EMPLOYEE ON ALL COLUMNS AND COLUMNS |
1.77778 |
RUNSTATS ON TABLE <SCHEMA_NAME>.ORG; |
SELECT STAFF.NAME, ORG.DEPTNUMB, ORG.DEPTNAME, STAFF.SALARY |
NAME DEPTNUMB DEPTNAME SALARY |
1 |
RUNSTATS ON TABLE <SCHEMA_NAME>.STAFF ON ALL COLUMNS AND COLUMNS ((ID, DEPT)); |
8 |
CREATE INDEX IX1 ON ORG (DEPTNUMB, DEPTNAME, MANAGER); |
db2look -d sample -e -a -m -t ORG -o org.ddl |
UPDATE SYSSTAT.COLGROUPS SET colgroupcard = 8 |
UPDATE SYSSTAT.INDEXES |
RUNSTATS ON TABLE <SCHEMA_NAME>.ORG ON ALL COLUMNS |
WITH TMP(ID, NUM) AS |
TABSCHEMA TABNAME COLS COLGROUPCARD |
WITH TMP(ID, NUM) AS |
SELECT SUBSTR(COLNAMES, 1, 30) AS COLS, FIRST2KEYCARD, FIRST3KEYCARD, |
COLS FIRST2KEYCARD FIRST3KEYCARD FIRST4KEYCARD FULLKEYCARD |
IXEMP_1 ON EMPLOYEE(JOB, WORKDEPT, SEX); |
RUNSTATS ON TABLE <SCHEMA_NAME>.EMPLOYEE AND INDEXES ALL; |
IXEMP_1 ON EMPLOYEE(JOB, WORKDEPT, SEX, EMPNO); |
P1: SHOW_LISTINGS.SHOW_ID = RATINGS.SHOW_ID |
P1: T1.C1=T2.C2 |
P1: T1.C1=T2.C3 |
P1: T1.C1=T2.C1 |
P1: T1.C1=T2.C2 |
RUNSTATS ON TABLE <SCHEMA_NAME>.ORG; |
SELECT STAFF.NAME, ORG.DEPTNUMB, ORG.DEPTNAME, STAFF.SALARY |
NAME DEPTNUMB DEPTNAME SALARY |
1 |
SELECT SUBSTR(COLNAME,1,20) AS COLNAME, COLCARD, |
COLNAME | COLCARD | HIGH2KEY | LOW2KEY |
DEPTNUMB | 8 | 66 | 15 |
MANAGER | 8 | 270 | 30 |
DEPT | 8 | 66 | 15 |
ID | 35 | 340 | 20 |
1/max(colcard_LHS,colcard_RHS). |
P1: org.manager=staff.id |
ff(P1) = 1 / max (8,35) = 1/35 = 0.0285714 |
JoinCard = Cardinality(ORG) * cardinality(STAFF) * ff(P1) * ff(P2) |
colcard(MANAGER) < colcard(ID) |
RUNSTATS ON TABLE <SCHEMA_NAME>.STAFF ON ALL COLUMNS AND COLUMNS ((ID,DEPT)); |
8 |
|
TABLENAME | COLNAME | COLCARD | HIGH2KEY | LOW2KEY | TABLENAME | COLNAME | COLCARD | HIGH2KEY | LOW2KEY |
T1 | C1 | 100 | 99 | 2 | T2 | C1 | 100 | 99 | 2 |
T1 | C2 | 10 | 1999 | 1900 | T2 | C2 | 10 | 1999 | 1900 |
T1 | C3 | 5 | 'Y' | 'B' | T2 | C3 | 5 | 'Y' | 'B' |
TABLENAME | COLNAME | COLCARD | HIGH2KEY | LOW2KEY | TABLENAME | COLNAME | COLCARD | HIGH2KEY | LOW2KEY |
T1 | C1 | 100 | 99 | 2 | T2 | C1 | 10 | 99 | 2 |
T1 | C2 | 10 | 1999 | 1900 | T2 | C2 | 10 | 1999 | 1900 |
T1 | C3 | 5 | 'Y' | 'B' | T2 | C3 | 5 | 'Y' | 'B' |
TABLENAME | COLNAME | COLCARD | HIGH2KEY | LOW2KEY | TABLENAME | COLNAME | COLCARD | HIGH2KEY | LOW2KEY |
T1 | C1 | 100 | 99 | 2 | T2 | C1 | 10 | 999 | 2 |
T1 | C2 | 10 | 1999 | 1900 | T2 | C2 | 10 | 1999 | 1900 |
T1 | C3 | 5 | 'Y' | 'B' | T2 | C3 | 5 | 'Y' | 'B' |
|
TABLENAME | COLNAME | COLCARD | HIGH2KEY | LOW2KEY | TABLENAME | COLNAME | COLCARD | HIGH2KEY | LOW2KEY |
T1 | C1 | 100 | 99 | 2 | T2 | C1 | 10 | 999 | 2 |
T1 | C2 | 10 | 1999 | 1900 | T2 | C2 | 10 | 1999 | 1900 |
T1 | C3 | 5 | 'Y' | 'B' | T2 | C3 | 5 | 'Y' | 'B' |
TABLENAME | COLNAME | COLCARD | HIGH2KEY | LOW2KEY | TABLENAME | COLNAME | COLCARD | HIGH2KEY | LOW2KEY |
T1 | C1 | 100 | 99 | 2 | T2 | C1 | 98 | 999 | 2 |
T1 | C2 | 10 | 1999 | 1900 | T2 | C2 | 11 | 1999 | 1900 |
T1 | C3 | 5 | 'Y' | 'B' | T2 | C3 | 5 | 'Y' | 'B' |
新闻热点
疑难解答