brin-builtin-opclasses.md 19.8 KB
Newer Older
K
KyleZhang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
## 68.2. Built-in Operator Classes

[68.2.1. Operator Class Parameters](brin-builtin-opclasses.html#BRIN-BUILTIN-OPCLASSES--PARAMETERS)

 The core PostgreSQL distribution includes the BRIN operator classes shown in [Table 68.1](brin-builtin-opclasses.html#BRIN-BUILTIN-OPCLASSES-TABLE).

 The *minmax* operator classes store the minimum and the maximum values appearing in the indexed column within the range. The *inclusion* operator classes store a value which includes the values in the indexed column within the range. The *bloom* operator classes build a Bloom filter for all values in the range. The *minmax-multi* operator classes store multiple minimum and maximum values, representing values appearing in the indexed column within the range.

**Table 68.1. Built-in BRIN Operator Classes**

|             Name             |     Indexable Operators     |
|------------------------------|-----------------------------|
|       `bit_minmax_ops`       |        `= (bit,bit)`        |
|        `< (bit,bit)`         |                             |
|        `> (bit,bit)`         |                             |
|        `<= (bit,bit)`        |                             |
|        `>= (bit,bit)`        |                             |
|     `box_inclusion_ops`      |      `@> (box,point)`       |
|        `<< (box,box)`        |                             |
|        `&< (box,box)`        |                             |
|        `&> (box,box)`        |                             |
|        `>> (box,box)`        |                             |
|        `<@ (box,box)`        |                             |
|        `@> (box,box)`        |                             |
|        `~= (box,box)`        |                             |
|        `&& (box,box)`        |                             |
|       `<<| (box,box)`        |                             |
|       `&<| (box,box)`        |                             |
|       `|&> (box,box)`        |                             |
|       `|>> (box,box)`        |                             |
|      `bpchar_bloom_ops`      |  `= (character,character)`  |
|     `bpchar_minmax_ops`      |  `= (character,character)`  |
|  `< (character,character)`   |                             |
|  `<= (character,character)`  |                             |
|  `> (character,character)`   |                             |
|  `>= (character,character)`  |                             |
|      `bytea_bloom_ops`       |      `= (bytea,bytea)`      |
|      `bytea_minmax_ops`      |      `= (bytea,bytea)`      |
|      `< (bytea,bytea)`       |                             |
|      `<= (bytea,bytea)`      |                             |
|      `> (bytea,bytea)`       |                             |
|      `>= (bytea,bytea)`      |                             |
|       `char_bloom_ops`       |     `= ("char","char")`     |
|      `char_minmax_ops`       |     `= ("char","char")`     |
|     `< ("char","char")`      |                             |
|     `<= ("char","char")`     |                             |
|     `> ("char","char")`      |                             |
|     `>= ("char","char")`     |                             |
|       `date_bloom_ops`       |       `= (date,date)`       |
|      `date_minmax_ops`       |       `= (date,date)`       |
|       `< (date,date)`        |                             |
|       `<= (date,date)`       |                             |
|       `> (date,date)`        |                             |
|       `>= (date,date)`       |                             |
|   `date_minmax_multi_ops`    |       `= (date,date)`       |
|       `< (date,date)`        |                             |
|       `<= (date,date)`       |                             |
|       `> (date,date)`        |                             |
|       `>= (date,date)`       |                             |
|      `float4_bloom_ops`      |     `= (float4,float4)`     |
|     `float4_minmax_ops`      |     `= (float4,float4)`     |
|     `< (float4,float4)`      |                             |
|     `> (float4,float4)`      |                             |
|     `<= (float4,float4)`     |                             |
|     `>= (float4,float4)`     |                             |
|  `float4_minmax_multi_ops`   |     `= (float4,float4)`     |
|     `< (float4,float4)`      |                             |
|     `> (float4,float4)`      |                             |
|     `<= (float4,float4)`     |                             |
|     `>= (float4,float4)`     |                             |
|      `float8_bloom_ops`      |     `= (float8,float8)`     |
|     `float8_minmax_ops`      |     `= (float8,float8)`     |
|     `< (float8,float8)`      |                             |
|     `<= (float8,float8)`     |                             |
|     `> (float8,float8)`      |                             |
|     `>= (float8,float8)`     |                             |
|  `float8_minmax_multi_ops`   |     `= (float8,float8)`     |
|     `< (float8,float8)`      |                             |
|     `<= (float8,float8)`     |                             |
|     `> (float8,float8)`      |                             |
|     `>= (float8,float8)`     |                             |
|     `inet_inclusion_ops`     |      `<< (inet,inet)`       |
|      `<<= (inet,inet)`       |                             |
|       `>> (inet,inet)`       |                             |
|      `>>= (inet,inet)`       |                             |
|       `= (inet,inet)`        |                             |
|       `&& (inet,inet)`       |                             |
|       `inet_bloom_ops`       |       `= (inet,inet)`       |
|      `inet_minmax_ops`       |       `= (inet,inet)`       |
|       `< (inet,inet)`        |                             |
|       `<= (inet,inet)`       |                             |
|       `> (inet,inet)`        |                             |
|       `>= (inet,inet)`       |                             |
|   `inet_minmax_multi_ops`    |       `= (inet,inet)`       |
|       `< (inet,inet)`        |                             |
|       `<= (inet,inet)`       |                             |
|       `> (inet,inet)`        |                             |
|       `>= (inet,inet)`       |                             |
|       `int2_bloom_ops`       |       `= (int2,int2)`       |
|      `int2_minmax_ops`       |       `= (int2,int2)`       |
|       `< (int2,int2)`        |                             |
|       `> (int2,int2)`        |                             |
|       `<= (int2,int2)`       |                             |
|       `>= (int2,int2)`       |                             |
|   `int2_minmax_multi_ops`    |       `= (int2,int2)`       |
|       `< (int2,int2)`        |                             |
|       `> (int2,int2)`        |                             |
|       `<= (int2,int2)`       |                             |
|       `>= (int2,int2)`       |                             |
|       `int4_bloom_ops`       |       `= (int4,int4)`       |
|      `int4_minmax_ops`       |       `= (int4,int4)`       |
|       `< (int4,int4)`        |                             |
|       `> (int4,int4)`        |                             |
|       `<= (int4,int4)`       |                             |
|       `>= (int4,int4)`       |                             |
|   `int4_minmax_multi_ops`    |       `= (int4,int4)`       |
|       `< (int4,int4)`        |                             |
|       `> (int4,int4)`        |                             |
|       `<= (int4,int4)`       |                             |
|       `>= (int4,int4)`       |                             |
|       `int8_bloom_ops`       |     `= (bigint,bigint)`     |
|      `int8_minmax_ops`       |     `= (bigint,bigint)`     |
|     `< (bigint,bigint)`      |                             |
|     `> (bigint,bigint)`      |                             |
|     `<= (bigint,bigint)`     |                             |
|     `>= (bigint,bigint)`     |                             |
|   `int8_minmax_multi_ops`    |     `= (bigint,bigint)`     |
|     `< (bigint,bigint)`      |                             |
|     `> (bigint,bigint)`      |                             |
|     `<= (bigint,bigint)`     |                             |
|     `>= (bigint,bigint)`     |                             |
|     `interval_bloom_ops`     |   `= (interval,interval)`   |
|    `interval_minmax_ops`     |   `= (interval,interval)`   |
|   `< (interval,interval)`    |                             |
|   `<= (interval,interval)`   |                             |
|   `> (interval,interval)`    |                             |
|   `>= (interval,interval)`   |                             |
| `interval_minmax_multi_ops`  |   `= (interval,interval)`   |
|   `< (interval,interval)`    |                             |
|   `<= (interval,interval)`   |                             |
|   `> (interval,interval)`    |                             |
|   `>= (interval,interval)`   |                             |
|     `macaddr_bloom_ops`      |    `= (macaddr,macaddr)`    |
|     `macaddr_minmax_ops`     |    `= (macaddr,macaddr)`    |
|    `< (macaddr,macaddr)`     |                             |
|    `<= (macaddr,macaddr)`    |                             |
|    `> (macaddr,macaddr)`     |                             |
|    `>= (macaddr,macaddr)`    |                             |
|  `macaddr_minmax_multi_ops`  |    `= (macaddr,macaddr)`    |
|    `< (macaddr,macaddr)`     |                             |
|    `<= (macaddr,macaddr)`    |                             |
|    `> (macaddr,macaddr)`     |                             |
|    `>= (macaddr,macaddr)`    |                             |
|     `macaddr8_bloom_ops`     |   `= (macaddr8,macaddr8)`   |
|    `macaddr8_minmax_ops`     |   `= (macaddr8,macaddr8)`   |
|   `< (macaddr8,macaddr8)`    |                             |
|   `<= (macaddr8,macaddr8)`   |                             |
|   `> (macaddr8,macaddr8)`    |                             |
|   `>= (macaddr8,macaddr8)`   |                             |
| `macaddr8_minmax_multi_ops`  |   `= (macaddr8,macaddr8)`   |
|   `< (macaddr8,macaddr8)`    |                             |
|   `<= (macaddr8,macaddr8)`   |                             |
|   `> (macaddr8,macaddr8)`    |                             |
|   `>= (macaddr8,macaddr8)`   |                             |
|       `name_bloom_ops`       |       `= (name,name)`       |
|      `name_minmax_ops`       |       `= (name,name)`       |
|       `< (name,name)`        |                             |
|       `<= (name,name)`       |                             |
|       `> (name,name)`        |                             |
|       `>= (name,name)`       |                             |
|     `numeric_bloom_ops`      |    `= (numeric,numeric)`    |
|     `numeric_minmax_ops`     |    `= (numeric,numeric)`    |
|    `< (numeric,numeric)`     |                             |
|    `<= (numeric,numeric)`    |                             |
|    `> (numeric,numeric)`     |                             |
|    `>= (numeric,numeric)`    |                             |
|  `numeric_minmax_multi_ops`  |    `= (numeric,numeric)`    |
|    `< (numeric,numeric)`     |                             |
|    `<= (numeric,numeric)`    |                             |
|    `> (numeric,numeric)`     |                             |
|    `>= (numeric,numeric)`    |                             |
|       `oid_bloom_ops`        |        `= (oid,oid)`        |
|       `oid_minmax_ops`       |        `= (oid,oid)`        |
|        `< (oid,oid)`         |                             |
|        `> (oid,oid)`         |                             |
|        `<= (oid,oid)`        |                             |
|        `>= (oid,oid)`        |                             |
|    `oid_minmax_multi_ops`    |        `= (oid,oid)`        |
|        `< (oid,oid)`         |                             |
|        `> (oid,oid)`         |                             |
|        `<= (oid,oid)`        |                             |
|        `>= (oid,oid)`        |                             |
|      `pg_lsn_bloom_ops`      |     `= (pg_lsn,pg_lsn)`     |
|     `pg_lsn_minmax_ops`      |     `= (pg_lsn,pg_lsn)`     |
|     `< (pg_lsn,pg_lsn)`      |                             |
|     `> (pg_lsn,pg_lsn)`      |                             |
|     `<= (pg_lsn,pg_lsn)`     |                             |
|     `>= (pg_lsn,pg_lsn)`     |                             |
|  `pg_lsn_minmax_multi_ops`   |     `= (pg_lsn,pg_lsn)`     |
|     `< (pg_lsn,pg_lsn)`      |                             |
|     `> (pg_lsn,pg_lsn)`      |                             |
|     `<= (pg_lsn,pg_lsn)`     |                             |
|     `>= (pg_lsn,pg_lsn)`     |                             |
|    `range_inclusion_ops`     |   `= (anyrange,anyrange)`   |
|   `< (anyrange,anyrange)`    |                             |
|   `<= (anyrange,anyrange)`   |                             |
|   `>= (anyrange,anyrange)`   |                             |
|   `> (anyrange,anyrange)`    |                             |
|   `&& (anyrange,anyrange)`   |                             |
|  `@> (anyrange,anyelement)`  |                             |
|   `@> (anyrange,anyrange)`   |                             |
|   `<@ (anyrange,anyrange)`   |                             |
|   `<< (anyrange,anyrange)`   |                             |
|   `>> (anyrange,anyrange)`   |                             |
|   `&< (anyrange,anyrange)`   |                             |
|   `&> (anyrange,anyrange)`   |                             |
|  `-|- (anyrange,anyrange)`   |                             |
|       `text_bloom_ops`       |       `= (text,text)`       |
|      `text_minmax_ops`       |       `= (text,text)`       |
|       `< (text,text)`        |                             |
|       `<= (text,text)`       |                             |
|       `> (text,text)`        |                             |
|       `>= (text,text)`       |                             |
|       `tid_bloom_ops`        |        `= (tid,tid)`        |
|       `tid_minmax_ops`       |        `= (tid,tid)`        |
|        `< (tid,tid)`         |                             |
|        `> (tid,tid)`         |                             |
|        `<= (tid,tid)`        |                             |
|        `>= (tid,tid)`        |                             |
|    `tid_minmax_multi_ops`    |        `= (tid,tid)`        |
|        `< (tid,tid)`         |                             |
|        `> (tid,tid)`         |                             |
|        `<= (tid,tid)`        |                             |
|        `>= (tid,tid)`        |                             |
|    `timestamp_bloom_ops`     |  `= (timestamp,timestamp)`  |
|    `timestamp_minmax_ops`    |  `= (timestamp,timestamp)`  |
|  `< (timestamp,timestamp)`   |                             |
|  `<= (timestamp,timestamp)`  |                             |
|  `> (timestamp,timestamp)`   |                             |
|  `>= (timestamp,timestamp)`  |                             |
| `timestamp_minmax_multi_ops` |  `= (timestamp,timestamp)`  |
|  `< (timestamp,timestamp)`   |                             |
|  `<= (timestamp,timestamp)`  |                             |
|  `> (timestamp,timestamp)`   |                             |
|  `>= (timestamp,timestamp)`  |                             |
|   `timestamptz_bloom_ops`    |`= (timestamptz,timestamptz)`|
|   `timestamptz_minmax_ops`   |`= (timestamptz,timestamptz)`|
|`< (timestamptz,timestamptz)` |                             |
|`<= (timestamptz,timestamptz)`|                             |
|`> (timestamptz,timestamptz)` |                             |
|`>= (timestamptz,timestamptz)`|                             |
|`timestamptz_minmax_multi_ops`|`= (timestamptz,timestamptz)`|
|`< (timestamptz,timestamptz)` |                             |
|`<= (timestamptz,timestamptz)`|                             |
|`> (timestamptz,timestamptz)` |                             |
|`>= (timestamptz,timestamptz)`|                             |
|       `time_bloom_ops`       |       `= (time,time)`       |
|      `time_minmax_ops`       |       `= (time,time)`       |
|       `< (time,time)`        |                             |
|       `<= (time,time)`       |                             |
|       `> (time,time)`        |                             |
|       `>= (time,time)`       |                             |
|   `time_minmax_multi_ops`    |       `= (time,time)`       |
|       `< (time,time)`        |                             |
|       `<= (time,time)`       |                             |
|       `> (time,time)`        |                             |
|       `>= (time,time)`       |                             |
|      `timetz_bloom_ops`      |     `= (timetz,timetz)`     |
|     `timetz_minmax_ops`      |     `= (timetz,timetz)`     |
|     `< (timetz,timetz)`      |                             |
|     `<= (timetz,timetz)`     |                             |
|     `> (timetz,timetz)`      |                             |
|     `>= (timetz,timetz)`     |                             |
|  `timetz_minmax_multi_ops`   |     `= (timetz,timetz)`     |
|     `< (timetz,timetz)`      |                             |
|     `<= (timetz,timetz)`     |                             |
|     `> (timetz,timetz)`      |                             |
|     `>= (timetz,timetz)`     |                             |
|       `uuid_bloom_ops`       |       `= (uuid,uuid)`       |
|      `uuid_minmax_ops`       |       `= (uuid,uuid)`       |
|       `< (uuid,uuid)`        |                             |
|       `> (uuid,uuid)`        |                             |
|       `<= (uuid,uuid)`       |                             |
|       `>= (uuid,uuid)`       |                             |
|   `uuid_minmax_multi_ops`    |       `= (uuid,uuid)`       |
|       `< (uuid,uuid)`        |                             |
|       `> (uuid,uuid)`        |                             |
|       `<= (uuid,uuid)`       |                             |
|       `>= (uuid,uuid)`       |                             |
|     `varbit_minmax_ops`      |     `= (varbit,varbit)`     |
|     `< (varbit,varbit)`      |                             |
|     `> (varbit,varbit)`      |                             |
|     `<= (varbit,varbit)`     |                             |
|     `>= (varbit,varbit)`     |                             |

### 68.2.1. Operator Class Parameters

 Some of the built-in operator classes allow specifying parameters affecting behavior of the operator class. Each operator class has its own set of allowed parameters. Only the `bloom` and `minmax-multi` operator classes allow specifying parameters:

 bloom operator classes accept these parameters:

`n_distinct_per_range`

 Defines the estimated number of distinct non-null values in the block range, used by BRIN bloom indexes for sizing of the Bloom filter. It behaves similarly to `n_distinct` option for [ALTER TABLE](sql-altertable.html). When set to a positive value, each block range is assumed to contain this number of distinct non-null values. When set to a negative value, which must be greater than or equal to -1, the number of distinct non-null values is assumed to grow linearly with the maximum possible number of tuples in the block range (about 290 rows per block). The default value is `-0.1`, and the minimum number of distinct non-null values is `16`.

`false_positive_rate`

 Defines the desired false positive rate used by BRIN bloom indexes for sizing of the Bloom filter. The values must be between 0.0001 and 0.25. The default value is 0.01, which is 1% false positive rate.

 minmax-multi operator classes accept these parameters:

`values_per_range`

 Defines the maximum number of values stored by BRIN minmax indexes to summarize a block range. Each value may represent either a point, or a boundary of an interval. Values must be between 8 and 256, and the default value is 32.