Sample Header Ad - 728x90

How indexes work in composite key and how changing the order affects the performance in Postgres 12?

1 vote
1 answer
646 views
CREATE TABLE public.ABC ( it_id TEXT NOT NULL, item_id varchar(50) NOT NULL, PRIMARY KEY (it_id,item_id) ); When I use above query then index scan is applied when i query only by it_id or by item_id or using both. But when I use the below then index scan is applied when I query with item_id or (item_id & it_id) . but not when I query with it_id only. CREATE TABLE public.ABC ( it_id TEXT NOT NULL, item_id varchar(50) NOT NULL, PRIMARY KEY (item_id,it_id) );
Asked by Utkal keshari Sahu (11 rep)
Jun 15, 2023, 05:47 AM
Last activity: Apr 23, 2025, 05:05 PM