CREATE INDEX request_response_partition_idx
ON public.request_response_partition USING btree (userid,extract('Month' from time_stamp));
我收到错误;
ERROR: functions in index expression must be marked IMMUTABLE
********** Error **********
ERROR: functions in index expression must be marked IMMUTABLE
SQL state: 42P17
[time_stamp
必须是timestamp with time zone
。
您必须在适当的时区将表达式IMMUTABLE
转换为timestamp without time zone
:
CREATE INDEX request_response_partition_idx
ON public.request_response_partition (
userid,
extract('Month' FROM (time_stamp AT TIME ZONE 'UTC'))
);
当然,您还必须修改查询中的表达式以匹配索引。