index on composite primary key columns

499 Views Asked by At

I have table called

CREATE TABLE process (
    batch_id      Integer
    ,product_id   Integer
    ,machine_id   Integer
    ,created_date DATE
    ,updated_date DATE
    ,primary key(batch_id,product_id,machine_id)
 )

But I generally use SQL like

SELECT *
FROM   process 
WHERE  product_id  = 123
AND    machine_id = 1

When i check SQL plan for this id does not uses primary key index.

Do i need to create another index of both columns?

Database is DB2

0

There are 0 best solutions below