1<!-- doc/src/sgml/brin.sgml --> 2 3<chapter id="brin"> 4<title>BRIN Indexes</title> 5 6 <indexterm> 7 <primary>index</primary> 8 <secondary>BRIN</secondary> 9 </indexterm> 10 11<sect1 id="brin-intro"> 12 <title>Introduction</title> 13 14 <para> 15 <acronym>BRIN</acronym> stands for Block Range Index. 16 <acronym>BRIN</acronym> is designed for handling very large tables 17 in which certain columns have some natural correlation with their 18 physical location within the table. 19 A <firstterm>block range</firstterm> is a group of pages that are physically 20 adjacent in the table; for each block range, some summary info is stored 21 by the index. 22 For example, a table storing a store's sale orders might have 23 a date column on which each order was placed, and most of the time 24 the entries for earlier orders will appear earlier in the table as well; 25 a table storing a ZIP code column might have all codes for a city 26 grouped together naturally. 27 </para> 28 29 <para> 30 <acronym>BRIN</acronym> indexes can satisfy queries via regular bitmap 31 index scans, and will return all tuples in all pages within each range if 32 the summary info stored by the index is <firstterm>consistent</firstterm> with the 33 query conditions. 34 The query executor is in charge of rechecking these tuples and discarding 35 those that do not match the query conditions — in other words, these 36 indexes are lossy. 37 Because a <acronym>BRIN</acronym> index is very small, scanning the index 38 adds little overhead compared to a sequential scan, but may avoid scanning 39 large parts of the table that are known not to contain matching tuples. 40 </para> 41 42 <para> 43 The specific data that a <acronym>BRIN</acronym> index will store, 44 as well as the specific queries that the index will be able to satisfy, 45 depend on the operator class selected for each column of the index. 46 Data types having a linear sort order can have operator classes that 47 store the minimum and maximum value within each block range, for instance; 48 geometrical types might store the bounding box for all the objects 49 in the block range. 50 </para> 51 52 <para> 53 The size of the block range is determined at index creation time by 54 the <literal>pages_per_range</literal> storage parameter. The number of index 55 entries will be equal to the size of the relation in pages divided by 56 the selected value for <literal>pages_per_range</literal>. Therefore, the smaller 57 the number, the larger the index becomes (because of the need to 58 store more index entries), but at the same time the summary data stored can 59 be more precise and more data blocks can be skipped during an index scan. 60 </para> 61 62 <sect2 id="brin-operation"> 63 <title>Index Maintenance</title> 64 65 <para> 66 At the time of creation, all existing heap pages are scanned and a 67 summary index tuple is created for each range, including the 68 possibly-incomplete range at the end. 69 As new pages are filled with data, page ranges that are already 70 summarized will cause the summary information to be updated with data 71 from the new tuples. 72 When a new page is created that does not fall within the last 73 summarized range, that range does not automatically acquire a summary 74 tuple; those tuples remain unsummarized until a summarization run is 75 invoked later, creating initial summaries. 76 This process can be invoked manually using the 77 <function>brin_summarize_range(regclass, bigint)</function> or 78 <function>brin_summarize_new_values(regclass)</function> functions; 79 automatically when <command>VACUUM</command> processes the table; 80 or by automatic summarization executed by autovacuum, as insertions 81 occur. (This last trigger is disabled by default and can be enabled 82 with the <literal>autosummarize</literal> parameter.) 83 Conversely, a range can be de-summarized using the 84 <function>brin_desummarize_range(regclass, bigint)</function> function, 85 which is useful when the index tuple is no longer a very good 86 representation because the existing values have changed. 87 </para> 88 89 <para> 90 When autosummarization is enabled, each time a page range is filled a 91 request is sent to autovacuum for it to execute a targeted summarization 92 for that range, to be fulfilled at the end of the next worker run on the 93 same database. If the request queue is full, the request is not recorded 94 and a message is sent to the server log: 95<screen> 96LOG: request for BRIN range summarization for index "brin_wi_idx" page 128 was not recorded 97</screen> 98 When this happens, the range will be summarized normally during the next 99 regular vacuum of the table. 100 </para> 101 </sect2> 102</sect1> 103 104<sect1 id="brin-builtin-opclasses"> 105 <title>Built-in Operator Classes</title> 106 107 <para> 108 The core <productname>PostgreSQL</productname> distribution 109 includes the <acronym>BRIN</acronym> operator classes shown in 110 <xref linkend="brin-builtin-opclasses-table"/>. 111 </para> 112 113 <para> 114 The <firstterm>minmax</firstterm> 115 operator classes store the minimum and the maximum values appearing 116 in the indexed column within the range. The <firstterm>inclusion</firstterm> 117 operator classes store a value which includes the values in the indexed 118 column within the range. 119 </para> 120 121 <table id="brin-builtin-opclasses-table"> 122 <title>Built-in <acronym>BRIN</acronym> Operator Classes</title> 123 <tgroup cols="3"> 124 <colspec colname="col1" colwidth="2*"/> 125 <colspec colname="col2" colwidth="2*"/> 126 <colspec colname="col3" colwidth="1*"/> 127 <thead> 128 <row> 129 <entry>Name</entry> 130 <entry>Indexed Data Type</entry> 131 <entry>Indexable Operators</entry> 132 </row> 133 </thead> 134 <tbody> 135 <row> 136 <entry><literal>int8_minmax_ops</literal></entry> 137 <entry><type>bigint</type></entry> 138 <entry> 139 <literal><</literal> 140 <literal><=</literal> 141 <literal>=</literal> 142 <literal>>=</literal> 143 <literal>></literal> 144 </entry> 145 </row> 146 <row> 147 <entry><literal>bit_minmax_ops</literal></entry> 148 <entry><type>bit</type></entry> 149 <entry> 150 <literal><</literal> 151 <literal><=</literal> 152 <literal>=</literal> 153 <literal>>=</literal> 154 <literal>></literal> 155 </entry> 156 </row> 157 <row> 158 <entry><literal>varbit_minmax_ops</literal></entry> 159 <entry><type>bit varying</type></entry> 160 <entry> 161 <literal><</literal> 162 <literal><=</literal> 163 <literal>=</literal> 164 <literal>>=</literal> 165 <literal>></literal> 166 </entry> 167 </row> 168 <row> 169 <entry><literal>box_inclusion_ops</literal></entry> 170 <entry><type>box</type></entry> 171 <entry> 172 <literal><<</literal> 173 <literal>&<</literal> 174 <literal>&&</literal> 175 <literal>&></literal> 176 <literal>>></literal> 177 <literal>~=</literal> 178 <literal>@></literal> 179 <literal><@</literal> 180 <literal>&<|</literal> 181 <literal><<|</literal> 182 <literal>|>></literal> 183 <literal>|&></literal> 184 </entry> 185 </row> 186 <row> 187 <entry><literal>bytea_minmax_ops</literal></entry> 188 <entry><type>bytea</type></entry> 189 <entry> 190 <literal><</literal> 191 <literal><=</literal> 192 <literal>=</literal> 193 <literal>>=</literal> 194 <literal>></literal> 195 </entry> 196 </row> 197 <row> 198 <entry><literal>bpchar_minmax_ops</literal></entry> 199 <entry><type>character</type></entry> 200 <entry> 201 <literal><</literal> 202 <literal><=</literal> 203 <literal>=</literal> 204 <literal>>=</literal> 205 <literal>></literal> 206 </entry> 207 </row> 208 <row> 209 <entry><literal>char_minmax_ops</literal></entry> 210 <entry><type>"char"</type></entry> 211 <entry> 212 <literal><</literal> 213 <literal><=</literal> 214 <literal>=</literal> 215 <literal>>=</literal> 216 <literal>></literal> 217 </entry> 218 </row> 219 <row> 220 <entry><literal>date_minmax_ops</literal></entry> 221 <entry><type>date</type></entry> 222 <entry> 223 <literal><</literal> 224 <literal><=</literal> 225 <literal>=</literal> 226 <literal>>=</literal> 227 <literal>></literal> 228 </entry> 229 </row> 230 <row> 231 <entry><literal>float8_minmax_ops</literal></entry> 232 <entry><type>double precision</type></entry> 233 <entry> 234 <literal><</literal> 235 <literal><=</literal> 236 <literal>=</literal> 237 <literal>>=</literal> 238 <literal>></literal> 239 </entry> 240 </row> 241 <row> 242 <entry><literal>inet_minmax_ops</literal></entry> 243 <entry><type>inet</type></entry> 244 <entry> 245 <literal><</literal> 246 <literal><=</literal> 247 <literal>=</literal> 248 <literal>>=</literal> 249 <literal>></literal> 250 </entry> 251 </row> 252 <row> 253 <entry><literal>network_inclusion_ops</literal></entry> 254 <entry><type>inet</type></entry> 255 <entry> 256 <literal>&&</literal> 257 <literal>>>=</literal> 258 <literal><<=</literal> 259 <literal>=</literal> 260 <literal>>></literal> 261 <literal><<</literal> 262 </entry> 263 </row> 264 <row> 265 <entry><literal>int4_minmax_ops</literal></entry> 266 <entry><type>integer</type></entry> 267 <entry> 268 <literal><</literal> 269 <literal><=</literal> 270 <literal>=</literal> 271 <literal>>=</literal> 272 <literal>></literal> 273 </entry> 274 </row> 275 <row> 276 <entry><literal>interval_minmax_ops</literal></entry> 277 <entry><type>interval</type></entry> 278 <entry> 279 <literal><</literal> 280 <literal><=</literal> 281 <literal>=</literal> 282 <literal>>=</literal> 283 <literal>></literal> 284 </entry> 285 </row> 286 <row> 287 <entry><literal>macaddr_minmax_ops</literal></entry> 288 <entry><type>macaddr</type></entry> 289 <entry> 290 <literal><</literal> 291 <literal><=</literal> 292 <literal>=</literal> 293 <literal>>=</literal> 294 <literal>></literal> 295 </entry> 296 </row> 297 <row> 298 <entry><literal>macaddr8_minmax_ops</literal></entry> 299 <entry><type>macaddr8</type></entry> 300 <entry> 301 <literal><</literal> 302 <literal><=</literal> 303 <literal>=</literal> 304 <literal>>=</literal> 305 <literal>></literal> 306 </entry> 307 </row> 308 <row> 309 <entry><literal>name_minmax_ops</literal></entry> 310 <entry><type>name</type></entry> 311 <entry> 312 <literal><</literal> 313 <literal><=</literal> 314 <literal>=</literal> 315 <literal>>=</literal> 316 <literal>></literal> 317 </entry> 318 </row> 319 <row> 320 <entry><literal>numeric_minmax_ops</literal></entry> 321 <entry><type>numeric</type></entry> 322 <entry> 323 <literal><</literal> 324 <literal><=</literal> 325 <literal>=</literal> 326 <literal>>=</literal> 327 <literal>></literal> 328 </entry> 329 </row> 330 <row> 331 <entry><literal>pg_lsn_minmax_ops</literal></entry> 332 <entry><type>pg_lsn</type></entry> 333 <entry> 334 <literal><</literal> 335 <literal><=</literal> 336 <literal>=</literal> 337 <literal>>=</literal> 338 <literal>></literal> 339 </entry> 340 </row> 341 <row> 342 <entry><literal>oid_minmax_ops</literal></entry> 343 <entry><type>oid</type></entry> 344 <entry> 345 <literal><</literal> 346 <literal><=</literal> 347 <literal>=</literal> 348 <literal>>=</literal> 349 <literal>></literal> 350 </entry> 351 </row> 352 <row> 353 <entry><literal>range_inclusion_ops</literal></entry> 354 <entry><type>any range type</type></entry> 355 <entry> 356 <literal><<</literal> 357 <literal>&<</literal> 358 <literal>&&</literal> 359 <literal>&></literal> 360 <literal>>></literal> 361 <literal>@></literal> 362 <literal><@</literal> 363 <literal>-|-</literal> 364 <literal>=</literal> 365 <literal><</literal> 366 <literal><=</literal> 367 <literal>=</literal> 368 <literal>></literal> 369 <literal>>=</literal> 370 </entry> 371 </row> 372 <row> 373 <entry><literal>float4_minmax_ops</literal></entry> 374 <entry><type>real</type></entry> 375 <entry> 376 <literal><</literal> 377 <literal><=</literal> 378 <literal>=</literal> 379 <literal>>=</literal> 380 <literal>></literal> 381 </entry> 382 </row> 383 <row> 384 <entry><literal>int2_minmax_ops</literal></entry> 385 <entry><type>smallint</type></entry> 386 <entry> 387 <literal><</literal> 388 <literal><=</literal> 389 <literal>=</literal> 390 <literal>>=</literal> 391 <literal>></literal> 392 </entry> 393 </row> 394 <row> 395 <entry><literal>text_minmax_ops</literal></entry> 396 <entry><type>text</type></entry> 397 <entry> 398 <literal><</literal> 399 <literal><=</literal> 400 <literal>=</literal> 401 <literal>>=</literal> 402 <literal>></literal> 403 </entry> 404 </row> 405 <row> 406 <entry><literal>tid_minmax_ops</literal></entry> 407 <entry><type>tid</type></entry> 408 <entry> 409 <literal><</literal> 410 <literal><=</literal> 411 <literal>=</literal> 412 <literal>>=</literal> 413 <literal>></literal> 414 </entry> 415 </row> 416 <row> 417 <entry><literal>timestamp_minmax_ops</literal></entry> 418 <entry><type>timestamp without time zone</type></entry> 419 <entry> 420 <literal><</literal> 421 <literal><=</literal> 422 <literal>=</literal> 423 <literal>>=</literal> 424 <literal>></literal> 425 </entry> 426 </row> 427 <row> 428 <entry><literal>timestamptz_minmax_ops</literal></entry> 429 <entry><type>timestamp with time zone</type></entry> 430 <entry> 431 <literal><</literal> 432 <literal><=</literal> 433 <literal>=</literal> 434 <literal>>=</literal> 435 <literal>></literal> 436 </entry> 437 </row> 438 <row> 439 <entry><literal>time_minmax_ops</literal></entry> 440 <entry><type>time without time zone</type></entry> 441 <entry> 442 <literal><</literal> 443 <literal><=</literal> 444 <literal>=</literal> 445 <literal>>=</literal> 446 <literal>></literal> 447 </entry> 448 </row> 449 <row> 450 <entry><literal>timetz_minmax_ops</literal></entry> 451 <entry><type>time with time zone</type></entry> 452 <entry> 453 <literal><</literal> 454 <literal><=</literal> 455 <literal>=</literal> 456 <literal>>=</literal> 457 <literal>></literal> 458 </entry> 459 </row> 460 <row> 461 <entry><literal>uuid_minmax_ops</literal></entry> 462 <entry><type>uuid</type></entry> 463 <entry> 464 <literal><</literal> 465 <literal><=</literal> 466 <literal>=</literal> 467 <literal>>=</literal> 468 <literal>></literal> 469 </entry> 470 </row> 471 </tbody> 472 </tgroup> 473 </table> 474</sect1> 475 476<sect1 id="brin-extensibility"> 477 <title>Extensibility</title> 478 479 <para> 480 The <acronym>BRIN</acronym> interface has a high level of abstraction, 481 requiring the access method implementer only to implement the semantics 482 of the data type being accessed. The <acronym>BRIN</acronym> layer 483 itself takes care of concurrency, logging and searching the index structure. 484 </para> 485 486 <para> 487 All it takes to get a <acronym>BRIN</acronym> access method working is to 488 implement a few user-defined methods, which define the behavior of 489 summary values stored in the index and the way they interact with 490 scan keys. 491 In short, <acronym>BRIN</acronym> combines 492 extensibility with generality, code reuse, and a clean interface. 493 </para> 494 495 <para> 496 There are four methods that an operator class for <acronym>BRIN</acronym> 497 must provide: 498 499 <variablelist> 500 <varlistentry> 501 <term><function>BrinOpcInfo *opcInfo(Oid type_oid)</function></term> 502 <listitem> 503 <para> 504 Returns internal information about the indexed columns' summary data. 505 The return value must point to a palloc'd <structname>BrinOpcInfo</structname>, 506 which has this definition: 507<programlisting> 508typedef struct BrinOpcInfo 509{ 510 /* Number of columns stored in an index column of this opclass */ 511 uint16 oi_nstored; 512 513 /* Opaque pointer for the opclass' private use */ 514 void *oi_opaque; 515 516 /* Type cache entries of the stored columns */ 517 TypeCacheEntry *oi_typcache[FLEXIBLE_ARRAY_MEMBER]; 518} BrinOpcInfo; 519</programlisting> 520 <structname>BrinOpcInfo</structname>.<structfield>oi_opaque</structfield> can be used by the 521 operator class routines to pass information between support functions 522 during an index scan. 523 </para> 524 </listitem> 525 </varlistentry> 526 527 <varlistentry> 528 <term><function>bool consistent(BrinDesc *bdesc, BrinValues *column, 529 ScanKey key)</function></term> 530 <listitem> 531 <para> 532 Returns whether the ScanKey is consistent with the given indexed 533 values for a range. 534 The attribute number to use is passed as part of the scan key. 535 </para> 536 </listitem> 537 </varlistentry> 538 539 <varlistentry> 540 <term><function>bool addValue(BrinDesc *bdesc, BrinValues *column, 541 Datum newval, bool isnull)</function></term> 542 <listitem> 543 <para> 544 Given an index tuple and an indexed value, modifies the indicated 545 attribute of the tuple so that it additionally represents the new value. 546 If any modification was done to the tuple, <literal>true</literal> is 547 returned. 548 </para> 549 </listitem> 550 </varlistentry> 551 552 <varlistentry> 553 <term><function>bool unionTuples(BrinDesc *bdesc, BrinValues *a, 554 BrinValues *b)</function></term> 555 <listitem> 556 <para> 557 Consolidates two index tuples. Given two index tuples, modifies the 558 indicated attribute of the first of them so that it represents both tuples. 559 The second tuple is not modified. 560 </para> 561 </listitem> 562 </varlistentry> 563 </variablelist> 564 565 An operator class for <acronym>BRIN</acronym> can optionally specify the 566 following method: 567 568 <variablelist> 569 <varlistentry> 570 <term><function>void options(local_relopts *relopts)</function></term> 571 <listitem> 572 <para> 573 Defines a set of user-visible parameters that control operator class 574 behavior. 575 </para> 576 577 <para> 578 The <function>options</function> function is passed a pointer to a 579 <replaceable>local_relopts</replaceable> struct, which needs to be 580 filled with a set of operator class specific options. The options 581 can be accessed from other support functions using the 582 <literal>PG_HAS_OPCLASS_OPTIONS()</literal> and 583 <literal>PG_GET_OPCLASS_OPTIONS()</literal> macros. 584 </para> 585 586 <para> 587 Since both key extraction of indexed values and representation of the 588 key in <acronym>BRIN</acronym> are flexible, they may depend on 589 user-specified parameters. 590 </para> 591 </listitem> 592 </varlistentry> 593 </variablelist> 594 595 The core distribution includes support for two types of operator classes: 596 minmax and inclusion. Operator class definitions using them are shipped for 597 in-core data types as appropriate. Additional operator classes can be 598 defined by the user for other data types using equivalent definitions, 599 without having to write any source code; appropriate catalog entries being 600 declared is enough. Note that assumptions about the semantics of operator 601 strategies are embedded in the support functions' source code. 602 </para> 603 604 <para> 605 Operator classes that implement completely different semantics are also 606 possible, provided implementations of the four main support functions 607 described above are written. Note that backwards compatibility across major 608 releases is not guaranteed: for example, additional support functions might 609 be required in later releases. 610 </para> 611 612 <para> 613 To write an operator class for a data type that implements a totally 614 ordered set, it is possible to use the minmax support functions 615 alongside the corresponding operators, as shown in 616 <xref linkend="brin-extensibility-minmax-table"/>. 617 All operator class members (functions and operators) are mandatory. 618 </para> 619 620 <table id="brin-extensibility-minmax-table"> 621 <title>Function and Support Numbers for Minmax Operator Classes</title> 622 <tgroup cols="2"> 623 <colspec colname="col1" colwidth="1*"/> 624 <colspec colname="col2" colwidth="2*"/> 625 <thead> 626 <row> 627 <entry>Operator class member</entry> 628 <entry>Object</entry> 629 </row> 630 </thead> 631 <tbody> 632 <row> 633 <entry>Support Function 1</entry> 634 <entry>internal function <function>brin_minmax_opcinfo()</function></entry> 635 </row> 636 <row> 637 <entry>Support Function 2</entry> 638 <entry>internal function <function>brin_minmax_add_value()</function></entry> 639 </row> 640 <row> 641 <entry>Support Function 3</entry> 642 <entry>internal function <function>brin_minmax_consistent()</function></entry> 643 </row> 644 <row> 645 <entry>Support Function 4</entry> 646 <entry>internal function <function>brin_minmax_union()</function></entry> 647 </row> 648 <row> 649 <entry>Operator Strategy 1</entry> 650 <entry>operator less-than</entry> 651 </row> 652 <row> 653 <entry>Operator Strategy 2</entry> 654 <entry>operator less-than-or-equal-to</entry> 655 </row> 656 <row> 657 <entry>Operator Strategy 3</entry> 658 <entry>operator equal-to</entry> 659 </row> 660 <row> 661 <entry>Operator Strategy 4</entry> 662 <entry>operator greater-than-or-equal-to</entry> 663 </row> 664 <row> 665 <entry>Operator Strategy 5</entry> 666 <entry>operator greater-than</entry> 667 </row> 668 </tbody> 669 </tgroup> 670 </table> 671 672 <para> 673 To write an operator class for a complex data type which has values 674 included within another type, it's possible to use the inclusion support 675 functions alongside the corresponding operators, as shown 676 in <xref linkend="brin-extensibility-inclusion-table"/>. It requires 677 only a single additional function, which can be written in any language. 678 More functions can be defined for additional functionality. All operators 679 are optional. Some operators require other operators, as shown as 680 dependencies on the table. 681 </para> 682 683 <table id="brin-extensibility-inclusion-table"> 684 <title>Function and Support Numbers for Inclusion Operator Classes</title> 685 <tgroup cols="3"> 686 <colspec colname="col1" colwidth="1*"/> 687 <colspec colname="col2" colwidth="2*"/> 688 <colspec colname="col3" colwidth="1*"/> 689 <thead> 690 <row> 691 <entry>Operator class member</entry> 692 <entry>Object</entry> 693 <entry>Dependency</entry> 694 </row> 695 </thead> 696 <tbody> 697 <row> 698 <entry>Support Function 1</entry> 699 <entry>internal function <function>brin_inclusion_opcinfo()</function></entry> 700 <entry></entry> 701 </row> 702 <row> 703 <entry>Support Function 2</entry> 704 <entry>internal function <function>brin_inclusion_add_value()</function></entry> 705 <entry></entry> 706 </row> 707 <row> 708 <entry>Support Function 3</entry> 709 <entry>internal function <function>brin_inclusion_consistent()</function></entry> 710 <entry></entry> 711 </row> 712 <row> 713 <entry>Support Function 4</entry> 714 <entry>internal function <function>brin_inclusion_union()</function></entry> 715 <entry></entry> 716 </row> 717 <row> 718 <entry>Support Function 11</entry> 719 <entry>function to merge two elements</entry> 720 <entry></entry> 721 </row> 722 <row> 723 <entry>Support Function 12</entry> 724 <entry>optional function to check whether two elements are mergeable</entry> 725 <entry></entry> 726 </row> 727 <row> 728 <entry>Support Function 13</entry> 729 <entry>optional function to check if an element is contained within another</entry> 730 <entry></entry> 731 </row> 732 <row> 733 <entry>Support Function 14</entry> 734 <entry>optional function to check whether an element is empty</entry> 735 <entry></entry> 736 </row> 737 <row> 738 <entry>Operator Strategy 1</entry> 739 <entry>operator left-of</entry> 740 <entry>Operator Strategy 4</entry> 741 </row> 742 <row> 743 <entry>Operator Strategy 2</entry> 744 <entry>operator does-not-extend-to-the-right-of</entry> 745 <entry>Operator Strategy 5</entry> 746 </row> 747 <row> 748 <entry>Operator Strategy 3</entry> 749 <entry>operator overlaps</entry> 750 <entry></entry> 751 </row> 752 <row> 753 <entry>Operator Strategy 4</entry> 754 <entry>operator does-not-extend-to-the-left-of</entry> 755 <entry>Operator Strategy 1</entry> 756 </row> 757 <row> 758 <entry>Operator Strategy 5</entry> 759 <entry>operator right-of</entry> 760 <entry>Operator Strategy 2</entry> 761 </row> 762 <row> 763 <entry>Operator Strategy 6, 18</entry> 764 <entry>operator same-as-or-equal-to</entry> 765 <entry>Operator Strategy 7</entry> 766 </row> 767 <row> 768 <entry>Operator Strategy 7, 13, 16, 24, 25</entry> 769 <entry>operator contains-or-equal-to</entry> 770 <entry></entry> 771 </row> 772 <row> 773 <entry>Operator Strategy 8, 14, 26, 27</entry> 774 <entry>operator is-contained-by-or-equal-to</entry> 775 <entry>Operator Strategy 3</entry> 776 </row> 777 <row> 778 <entry>Operator Strategy 9</entry> 779 <entry>operator does-not-extend-above</entry> 780 <entry>Operator Strategy 11</entry> 781 </row> 782 <row> 783 <entry>Operator Strategy 10</entry> 784 <entry>operator is-below</entry> 785 <entry>Operator Strategy 12</entry> 786 </row> 787 <row> 788 <entry>Operator Strategy 11</entry> 789 <entry>operator is-above</entry> 790 <entry>Operator Strategy 9</entry> 791 </row> 792 <row> 793 <entry>Operator Strategy 12</entry> 794 <entry>operator does-not-extend-below</entry> 795 <entry>Operator Strategy 10</entry> 796 </row> 797 <row> 798 <entry>Operator Strategy 20</entry> 799 <entry>operator less-than</entry> 800 <entry>Operator Strategy 5</entry> 801 </row> 802 <row> 803 <entry>Operator Strategy 21</entry> 804 <entry>operator less-than-or-equal-to</entry> 805 <entry>Operator Strategy 5</entry> 806 </row> 807 <row> 808 <entry>Operator Strategy 22</entry> 809 <entry>operator greater-than</entry> 810 <entry>Operator Strategy 1</entry> 811 </row> 812 <row> 813 <entry>Operator Strategy 23</entry> 814 <entry>operator greater-than-or-equal-to</entry> 815 <entry>Operator Strategy 1</entry> 816 </row> 817 </tbody> 818 </tgroup> 819 </table> 820 821 <para> 822 Support function numbers 1 through 10 are reserved for the BRIN internal 823 functions, so the SQL level functions start with number 11. Support 824 function number 11 is the main function required to build the index. 825 It should accept two arguments with the same data type as the operator class, 826 and return the union of them. The inclusion operator class can store union 827 values with different data types if it is defined with the 828 <literal>STORAGE</literal> parameter. The return value of the union 829 function should match the <literal>STORAGE</literal> data type. 830 </para> 831 832 <para> 833 Support function numbers 12 and 14 are provided to support 834 irregularities of built-in data types. Function number 12 835 is used to support network addresses from different families which 836 are not mergeable. Function number 14 is used to support 837 empty ranges. Function number 13 is an optional but 838 recommended one, which allows the new value to be checked before 839 it is passed to the union function. As the BRIN framework can shortcut 840 some operations when the union is not changed, using this 841 function can improve index performance. 842 </para> 843 844 <para> 845 Both minmax and inclusion operator classes support cross-data-type 846 operators, though with these the dependencies become more complicated. 847 The minmax operator class requires a full set of operators to be 848 defined with both arguments having the same data type. It allows 849 additional data types to be supported by defining extra sets 850 of operators. Inclusion operator class operator strategies are dependent 851 on another operator strategy as shown in 852 <xref linkend="brin-extensibility-inclusion-table"/>, or the same 853 operator strategy as themselves. They require the dependency 854 operator to be defined with the <literal>STORAGE</literal> data type as the 855 left-hand-side argument and the other supported data type to be the 856 right-hand-side argument of the supported operator. See 857 <literal>float4_minmax_ops</literal> as an example of minmax, and 858 <literal>box_inclusion_ops</literal> as an example of inclusion. 859 </para> 860</sect1> 861</chapter> 862