错误 "functions in index expression must be marked IMMUTABLE",不是时间戳
Error "functions in index expression must be marked IMMUTABLE", not time stamp
我正在尝试创建以下索引;
CREATE INDEX idx_concat_paostartno_paostartsuff ON
dmv_os_addbase_residential (concat(pao_start_number || pao_start_suffix));
我收到错误;
ERROR: functions in index expression must be marked IMMUTABLE`
我认为这是类型的混合,因为 pao_start_number
是类型 bigint
而 pao_start_suffix
是 varchar
。我试图解决为;
CREATE INDEX idx_concat_paostartno_paostartsuff ON
dmv_os_addbase_residential (concat((pao_start_number :: text) || pao_start_suffix))
但同样的错误。
我是否正确地确定了错误的原因以及如何解决它?
我正在使用 Postgres 9.6
你可能想要
CREATE INDEX idx_concat_paostartno_paostartsuff
ON dmv_os_addbase_residential ((pao_start_number || pao_start_suffix));
这个索引只能用于像
这样的查询
SELECT *
FROM dmv_os_addbase_residential
WHERE pao_start_number || pao_start_suffix <operator> <constant>;
其中 <operator>
是 =
、<
、<=
、>
或 >=
之一。
Postgres 认为时区感知时间戳是可变的。这就是它失败的原因。我发现以下 GIST 为我解决了这个问题:
https://gist.github.com/cobusc/5875282
GIST 内容的快捷方式(感谢 cobusc):
CREATE INDEX my_index_name_idx ON my_table (date(created_ts at TIME ZONE 'UTC'));
对我有用
我正在尝试创建以下索引;
CREATE INDEX idx_concat_paostartno_paostartsuff ON
dmv_os_addbase_residential (concat(pao_start_number || pao_start_suffix));
我收到错误;
ERROR: functions in index expression must be marked IMMUTABLE`
我认为这是类型的混合,因为 pao_start_number
是类型 bigint
而 pao_start_suffix
是 varchar
。我试图解决为;
CREATE INDEX idx_concat_paostartno_paostartsuff ON
dmv_os_addbase_residential (concat((pao_start_number :: text) || pao_start_suffix))
但同样的错误。
我是否正确地确定了错误的原因以及如何解决它? 我正在使用 Postgres 9.6
你可能想要
CREATE INDEX idx_concat_paostartno_paostartsuff
ON dmv_os_addbase_residential ((pao_start_number || pao_start_suffix));
这个索引只能用于像
这样的查询SELECT *
FROM dmv_os_addbase_residential
WHERE pao_start_number || pao_start_suffix <operator> <constant>;
其中 <operator>
是 =
、<
、<=
、>
或 >=
之一。
Postgres 认为时区感知时间戳是可变的。这就是它失败的原因。我发现以下 GIST 为我解决了这个问题: https://gist.github.com/cobusc/5875282
GIST 内容的快捷方式(感谢 cobusc):
CREATE INDEX my_index_name_idx ON my_table (date(created_ts at TIME ZONE 'UTC'));
对我有用