ERROR: Functions in index expression must be marked IMMUTABLE
在创建函数索引时遇到报错,报错信息即为标题,下面是详细信息。
1 表定义
1 |
skytf=> \d test_39; |
现在需要在字段 “skyid”, “create_time” 上创建联合索引。
2 创建索引
1 |
skytf=> create index CONCURRENTLY idx_test_skyid_ctime on test_39 using btree (skyid, to_char(create_time, 'YYYY-MM-DD') ); |
创建函数索引报错,”functions in index expression must be marked IMMUTABLE” ,意思为建立函数索引时 函数必须标识为 “IMMUTABLE”。
3 查看 to_char 函数
1 |
skytf=> \df to_char(); |
4 以 postgres 超级用户连接,修改 to_char 函数属性
1 |
skytf=# alter function to_char(timestamp with time zone, text) IMMUTABLE; |
备注:由于表 test_39 上的列 create_time 类型为 “timestamp with time zone” , 所以修改函数时应该修改函数 to_char(timestamp with time zone, text),为了安全己见,不要直接修改 to_char 函数,建议新建一个 IMMUTABLE 属性的 to_char_immutable 函数。
5 验证是否生效
1 |
skytf=> \ef to_char(timestamp with time zone, text) |
从“IMMUTABLE STRICT” 中可以看出,函数已经修改成 “IMMUTABLE”属性。
6 以 skytf 连接, 再次创建索引
1 |
skytf=> create index CONCURRENTLY idx_test_skyid_ctime on test_39 using btree (skyid, to_char(create_time, 'YYYY-MM-DD') ); |
备注:在修改函数 to_char(timestamp with time zone, text) 属性后,创建索引就成功了。
1 |
skytf=> \d test_39 |
7 手册上关于 “IMMUTABLE” 属性解释
IMMUTABLE indicates that the function cannot modify the database and always returns the same result when given the same argument values; that is, it does not do database lookups or otherwise use information not directly present in its argument list. If this option is given, any call of the function with all-constant arguments can be immediately replaced with the function value.
8 总结
函数的默认属性为 “VOLATILE”, 即可变的,在创建函数索引时,需要将引用函数的属性改为”IMMUTABLE”, 即稳定的,函数索引才能创建成功。也就是说,只有属性为稳定的函数,才能用来创建函数索引。
ERROR: Functions in index expression must be marked IMMUTABLE的更多相关文章
- Error: Error setting TTL index on collection : sessions
Error: Error setting TTL index on collection : sessions 一.步骤一: 这个问题一般是直接升级 mongodb和connect-mongo的版本为 ...
- Solve Error Debug Assertion Failed Expression vector iterators incompatible Using PCL in Release Mode of VS2010
When using PCL 1.4.0 in the release mode building under VS2010, we might sometime get the error &quo ...
- 解决报错error the @annotation pointcut expression is only supported at Java 5
eclipse搭建环境后报错 error the @annotation pointcut expression is only supported at Java 5 错误意思大致是:注释切入点表达 ...
- 编译时错误之 error C2338: tuple_element index out of bounds
part 1 编译器 vs2015 VC++. 完整的错误信息粘贴如下: d:\program files (x86)\microsoft visual studio 14.0\vc\include\ ...
- Type Syntax error, insert ")" to complete Expression
今天倒持了 几个小时! 愣是 没有明确 ,为什么我的JSP的第一行没有代码? 还是报错! 错误是: Description Resource Path Location Type Sy ...
- bullet, iOS真机编译错误error: identifier or immediate expression expected解决方法
刚才发现c3dEngine2(http://git.oschina.net/wantnon2/c3dEngine2 或 https://github.com/wantnon2/c3dEngine2)的 ...
- ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.
MySQL版本5.6.35 在一个长度为512字符的字段上创建unique key报错 CREATE DATABASE dpcs_metadata DEFAULT CHARACTER SET utf8 ...
- C++ error:Debug Assertion Failed.Expression:_BLOCK_TYPE_IS_VALID(phead->nBlock)
Debug Assertion Failed.Expression:_BLOCK_TYPE_IS_VALID(phead->nBlockUse) 关于上面这个错误,我在上一篇文章中的程序遇到过了 ...
- error the @annotation pointcut expression is only supported at Java 5 compliance
今天碰到这个错误,在网上找了下,是因为aspectjweaver.jar用的是1.5.3 本地eclipse的jdk版本为1.7 下载高版本的aspectjweaver.jar会解决此问题 http: ...
- digestmd5.c:4037:15: error: #elif with no expression
执行如下:sed -i.bak 's/#elif WITH_DES/#elif defined(WITH_DES)/' \ plugins/digestmd5.c
随机推荐
- VSCODE 中.art文件识别为html文件
setting.json文件中 { "git.ignoreMissingGitWarning": true, "explorer.confirmDelete": ...
- 1.5.5 HDFS读写解析-hadoop-最全最完整的保姆级的java大数据学习资料
目录 1.5.5 HDFS读写解析 1.5.5.1 HDFS读数据流程 1.5.5.2 HDFS写数据流程 1.5.5 HDFS读写解析 1.5.5.1 HDFS读数据流程 客户端通过Distribu ...
- Relational Learning with Gated and Attentive Neighbor Aggregator for Few-Shot Knowledge Graph Completion 小样本关系学习论文解读
小样本知识图补全--关系学习.利用三元组的邻域信息,提升模型的关系表示学习,来实现小样本的链接预测.主要应用的思想和模型包括:GAT.TransH.SLTM.Model-Agnostic Meta-L ...
- 【转载】【WinAPI】LockWindowUpdate的函数的用法
DelPhi LockWindowUpdate的函数的用法 Application.ProcessMessages; LockWindowUpdate(Self.Handle); //锁住当前窗口 L ...
- APICloud 入门教程窗口篇
什么是窗口,窗口可以理解为一屏幕内容的一个基本载体,里面可以放导航,图片,视频,文字等组成一屏幕内容. 不同的窗口组成一个APP, 例如购物APP有[首页],[购物车],[我的]等不同的窗口.不同的窗 ...
- C#调用接口的简单流程
1.编写url地址 string url="http://192.168"; 2.创建http请求对象 HttpWebRequest request = (HttpWebReque ...
- Profiler导致的严重性能问题
背景 客户反馈系统突然运行非常缓慢,持续了近20分钟的时间,通过SQL专家云定位到有人开启了Profiler导致,但是不能定位是谁开启的,请我们协助分析. 现象 登录SQL专家云,进入实时可视化页面 ...
- Pytorch基础-tensor数据结构
torch.Tensor Tensor 数据类型 Tensor 的属性 view 和 reshape 的区别 Tensor 与 ndarray 创建 Tensor 传入维度的方法 参考资料 torch ...
- python之路54 forms组件 渲染 展示 参数补充 modelform组件 django中间件
forms组件渲染标签 <p>forms组件渲染标签的方式1(封装程度高 扩展性差 主要用于本地测试):</p> {# {{ form_obj.as_p }}#} {# {{ ...
- NET-async-await是否会创建新线程
title: .NET async/await是否会创建新线程 date: 2022-12-06 10:36:46 tags: - .NET 先上结论 CPU密集型操作,比如计算,如果不使用Task, ...