postgresql - Should index include a 'constant' column? -


i doing partitioning in postgres db. root table kpis_weekly(date, personid, metric, value) , partition table kpis_weekly_yyyymmdd inherits kpis_weekly table. set primary key of child table (personid, metric), date same in same partition table.

is right practice? or should create primary key on (date, personid, metric), although date 'constant' inside same partition table.

the queries run on table like:

select *  kpis_weekly   date = '2011-02-20'  , personid = 50  select *  kpis_weekly   date = '2011-02-20'  , metric = 'centrality'  , personid in ( 50, 82, 10, 14, 22, 36) 

if pair personid - metric unique yes, it's better have primary key based on these 2 columns. in case primary key of master table cannot propagated child tables, including date key useless.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -