↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / 运算符族 / B-tree 操作符家族

btree/datetime_ops (family)

B-tree 操作符家族 containing 3 classes, 45 operator strategies and 21 support functions in this source build。

当前查看 PostgreSQL 18.6。

说明

B-tree 操作符家族 containing 3 classes, 45 operator strategies and 21 support functions in this source build。

对象种类
操作符家族
索引访问方法
B-tree

用法

btree/datetime_ops

操作符类与家族

一个索引定义可以为索引的每一列指定一个 操作符类 。

操作符类标识该索引在该列上要使用哪些操作符。例如,类型 int4 上的一个 B-树索引会使用 int4_ops 类;这个操作符类包含对 int4 值进行比较所需的函数。实践中,列数据类型的默认操作符类通常已经足够。之所以存在操作符类,主要是因为对某些数据类型来说,可能存在多种有意义的索引行为。例如,我们可能希望按绝对值排序一种复数数据类型,也可能希望按实部排序。我们可以通过为该数据类型定义两个操作符类,并在创建索引时选择合适的那个来做到这一点。操作符类决定了基础排序顺序(之后还可以通过添加排序选项 COLLATE 、 ASC / DESC 和/或 NULLS FIRST / NULLS LAST 来修改)。

除了默认操作符类之外,还有一些内置操作符类:

家族中的操作符策略

操作符重载策略用途排序家族成员范围源码说明
<(date,date)1搜索家族成员小于
<=(date,date)2搜索家族成员小于等于
=(date,date)3搜索家族成员等于
>=(date,date)4搜索家族成员大于等于
>(date,date)5搜索家族成员大于
<(date,timestamp)1搜索家族成员小于
<=(date,timestamp)2搜索家族成员小于等于
=(date,timestamp)3搜索家族成员等于
>=(date,timestamp)4搜索家族成员大于等于
>(date,timestamp)5搜索家族成员大于
<(date,timestamptz)1搜索家族成员小于
<=(date,timestamptz)2搜索家族成员小于等于
=(date,timestamptz)3搜索家族成员等于
>=(date,timestamptz)4搜索家族成员大于等于
>(date,timestamptz)5搜索家族成员大于
<(timestamp,timestamp)1搜索家族成员小于
<=(timestamp,timestamp)2搜索家族成员小于等于
=(timestamp,timestamp)3搜索家族成员等于
>=(timestamp,timestamp)4搜索家族成员大于等于
>(timestamp,timestamp)5搜索家族成员大于
<(timestamp,date)1搜索家族成员小于
<=(timestamp,date)2搜索家族成员小于等于
=(timestamp,date)3搜索家族成员等于
>=(timestamp,date)4搜索家族成员大于等于
>(timestamp,date)5搜索家族成员大于
<(timestamp,timestamptz)1搜索家族成员小于
<=(timestamp,timestamptz)2搜索家族成员小于等于
=(timestamp,timestamptz)3搜索家族成员等于
>=(timestamp,timestamptz)4搜索家族成员大于等于
>(timestamp,timestamptz)5搜索家族成员大于
<(timestamptz,timestamptz)1搜索家族成员小于
<=(timestamptz,timestamptz)2搜索家族成员小于等于
=(timestamptz,timestamptz)3搜索家族成员等于
>=(timestamptz,timestamptz)4搜索家族成员大于等于
>(timestamptz,timestamptz)5搜索家族成员大于
<(timestamptz,date)1搜索家族成员小于
<=(timestamptz,date)2搜索家族成员小于等于
=(timestamptz,date)3搜索家族成员等于
>=(timestamptz,date)4搜索家族成员大于等于
>(timestamptz,date)5搜索家族成员大于
<(timestamptz,timestamp)1搜索家族成员小于
<=(timestamptz,timestamp)2搜索家族成员小于等于
=(timestamptz,timestamp)3搜索家族成员等于
>=(timestamptz,timestamp)4搜索家族成员大于等于
>(timestamptz,timestamp)5搜索家族成员大于

家族支持函数

支持函数编号左侧类型右侧类型函数签名返回类型
1datedatedate_cmp(date,date)int4
2datedatedate_sortsupport(internal)void
4datedatebtequalimage(oid)bool
6datedatedate_skipsupport(internal)void
1datetimestampdate_cmp_timestamp(date,timestamp)int4
1datetimestamptzdate_cmp_timestamptz(date,timestamptz)int4
1timestamptimestamptimestamp_cmp(timestamp,timestamp)int4
2timestamptimestamptimestamp_sortsupport(internal)void
4timestamptimestampbtequalimage(oid)bool
6timestamptimestamptimestamp_skipsupport(internal)void
1timestampdatetimestamp_cmp_date(timestamp,date)int4
1timestamptimestamptztimestamp_cmp_timestamptz(timestamp,timestamptz)int4
1timestamptztimestamptztimestamptz_cmp(timestamptz,timestamptz)int4
2timestamptztimestamptztimestamp_sortsupport(internal)void
4timestamptztimestamptzbtequalimage(oid)bool
6timestamptztimestamptztimestamp_skipsupport(internal)void
1timestamptzdatetimestamptz_cmp_date(timestamptz,date)int4
1timestamptztimestamptimestamptz_cmp_timestamp(timestamptz,timestamp)int4
3dateintervalin_range(date,date,interval,bool,bool)bool
3timestampintervalin_range(timestamp,timestamp,interval,bool,bool)bool
3timestamptzintervalin_range(timestamptz,timestamptz,interval,bool,bool)bool

本家族的操作符类

操作符类输入类型键类型默认值
date_opsdate与输入类型相同是
timestamptz_opstimestamptz与输入类型相同是
timestamp_opstimestamp与输入类型相同是

相关条目

文档与源码

来源构建
版本
18.6
构建
https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
来源指纹
555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f

版本比较

PostgreSQL 12 → 13: 属性变化。

以下差异保留原始字段名与英文源描述。

--- PostgreSQL 12
+++ PostgreSQL 13
@@ -617,6 +617,33 @@
       "number": "3",
       "result_type": "bool",
       "right_type": "interval"
+    },
+    {
+      "family": "datetime_ops",
+      "function": "btequalimage(oid)",
+      "left_type": "date",
+      "method": "btree",
+      "number": "4",
+      "result_type": "bool",
+      "right_type": "date"
+    },
+    {
+      "family": "datetime_ops",
+      "function": "btequalimage(oid)",
+      "left_type": "timestamp",
+      "method": "btree",
+      "number": "4",
+      "result_type": "bool",
+      "right_type": "timestamp"
+    },
+    {
+      "family": "datetime_ops",
+      "function": "btequalimage(oid)",
+      "left_type": "timestamptz",
+      "method": "btree",
+      "number": "4",
+      "result_type": "bool",
+      "right_type": "timestamptz"
     }
   ]
 }

比较已记录的接口与属性,排除来源指纹和构建元数据。某个样本中没有记录,不能据此判断实际引入或移除的版本。

相关条目

导出 JSON · 返回运算符族 · 收录范围为 PostgreSQL 10 至 20;最早采样版本不一定是实际引入版本。