I have a table in a PostGreSql database defined as following:
CREATE TABLE public."MATCH"(
"ITEM_A_ID" bigint DEFAULT 0,
"ITEM_B_ID" bigint DEFAULT 0,
"OWNER_A_ID" bigint DEFAULT 0,
"OWNER_B_ID" bigint DEFAULT 0,
"OTHER_DATA" varchar(100) NOT NULL DEFAULT ''
CONSTRAINT "MATCH_PK" PRIMARY KEY ("ITEM_A_ID","ITEM_B_ID")
);
It will contain a lot of rows. There will be a lot of queries like the following performed on this table:
SELECT * FROM "MATCH" WHERE "OWNER_A_ID" = owner_a_id;
SELECT * FROM "MATCH" WHERE "OWNER_B_ID" = owner_b_id;
I was thinking about creating indexes on OWNER_A_ID
and OWNER_B_ID
, since these columns are not keys. Is this a good idea, and if yes, how should I create these? Should I create one index with both columns? Should I create two indexes? Should I include other columns?