Hi,
I'm using DB2 10.1 ESE on Windows.
I have two tables, each one has 200K rows.
CREATE TABLE SYSREPORTS(
actId INTEGER NOT NULL,
propId INTEGER NOT NULL,
bckId INTEGER NOT NULL,
sysId INTEGER NOT NULL,
failed SMALLINT NOT NULL,
template SMALLINT NOT NULL,
description VARCHAR(8000),
rnum BIGINT NOT NULL,
address BIGINT NOT NULL
CONSTRAINT pk_sysreports PRIMARY KEY ( actId, propId, bckId, sysId )
);
CREATE TABLE SMART_PCS(
id INTEGER NOT NULL,
);
SYSREPORTS has a further index, not UNIQUE, on sysId.
If I run this query
select S.sysid FROM SMART_PCS C
JOIN SYSREPORTS S ON S.sysId= C.id
WHERE S.actId = p_actId AND S.propId = p_propId AND S.sysId = p_sysId for read only;
it takes less than a second, if I run
select S.sysid, S.description, S.rnum FROM SMART_PCS C
JOIN SYSREPORTS S ON S.sysId= C.id
WHERE S.actId = p_actId AND S.propId = p_propId AND S.sysId = p_sysId for read only;
it takes more than 400 seconds.
I cannot include description and rnum in the index since it would require the index to be unique (and I don't want it).
How can I solve this issue?