Content deleted Content added
Viam Ferream (talk | contribs) m →Design |
m →Design |
||
(25 intermediate revisions by 18 users not shown) | |||
Line 1:
{{Short description|Database indexing technique}}
A '''Block Range Index''' or '''BRIN''' is a [[database index]]ing technique. They are intended to improve performance with extremely large{{efn-lr|'Large' here refers to the number of rows in a [[database table|table]], rather than the field sizes or overall size.}} tables.
Line 9 ⟶ 10:
}}</ref>
A BRIN is applicable to an index on a table that is large and where the index key value is easily sorted and evaluated with a [[MinMax function]].{{efn-lr|A function which efficiently evaluates a large number of data items and returns their minimum and maximum values. The concepts of "minimum" and "maximum" are broad and may be applied to any data type, or their combinations, which is [[sorting algorithm|sortable]].}}
BRIN were originally proposed by Alvaro Herrera of [[
|title=Minmax indexes
|date=2013-06-14
Line 27 ⟶ 28:
|title=Chapter 62. BRIN Indexes
|url=http://www.postgresql.org/docs/9.5/static/brin-intro.html
}}</ref> Other vendors have described some similar features,<ref name="Herrera, 2013"/> including [[Oracle database|Oracle]],<ref name="Oracle, Exadata Storage Indexes"/><ref name=Solarwinds/> [[Netezza]] 'zone maps',<ref>{{cite web|url=http://nztips.com/2010/11/netezza-integer-join-keys/ |publisher=Netezza|title=With Netezza Always Use Integer Join Keys For Good Compression, Zone Maps, And Joins|year=2010}}</ref> [[Infobright]] 'data packs',<ref>{{cite web|title=Data packs
== Design ==
[[File:B-tree.svg|thumb|B-tree index structure]]
[[File:BRIN index.svg|thumb|BRIN index structure]]BRIN operate by "summarising" large blocks of data into a compact form, which can be efficiently tested to exclude many of them from a database query, early on. These tests exclude a large block of data for each comparison. By reducing the data volume so early on, both by representing large blocks as small tuples, and by eliminating many blocks, BRIN substantially reduce the amount of detailed data that must be examined by the database node on a row-by-row basis.<ref>{{Cite web |last1=Herrera |first1=Alvaro |date=7 November 2014 |title=commitdiff - BRIN: Block Range Indexes |url=https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=7516f5259411c02ae89e49084452dc342aadb2ae |website=git.postgresql.org |access-date=2017-10-03}}</ref>
Data storage in large databases is layered and chunked, with the table storage arranged into 'blocks'. Each block contains perhaps 1MB in each chunk{{efn-lr| PostgreSQL has a default
|title=PostgreSQL Performance Presentation
|author=Mark Wong
|date=10 March 2015
|pages=
|url=https://axleproject2015.files.wordpress.com/2015/03/postgresql-performance-presentation-sfpgday2015.pdf
}}</ref>
Unlike a traditional index which ''locates'' the regions of the table containing values of interest, BRIN act as "negative indexes",<ref name="Oracle, Exadata Storage Indexes"/> showing the blocks that are definitely ''not'' of interest and thus do not need to be processed further.
Line 49 ⟶ 46:
Some simple benchmarks suggest a five-fold improvement in search performance with an index scan, compared to the unindexed table.<ref name="Wahts new"/> Compared to B-trees, they avoid their maintenance overhead.<ref name="Herrera, 2013"/>
As BRIN are so lightweight, they may be held entirely in memory, thus avoiding disk overhead during the scan. The same may not be true of B-tree: B-tree requires a tree node for every approximately ''
|title= Block Range (BRIN) Indexes in PostgreSQL 9.5
|date=May 22, 2015
Line 57 ⟶ 54:
== Advantages ==
=== Search and index scan ===
A large database index would typically use [[B-tree]] algorithms. BRIN is not always a substitute for B-tree, it is an improvement on sequential scanning of an index, with particular (and potentially large) advantages when the index meets particular conditions for being ordered and for the search target to be a narrow set of these values. In the general case, with random data, B-tree may still be superior.<ref name="Wahts new"/>
A particular advantage of the BRIN technique, shared with Oracle Exadata's Smart Scanning,<ref name=Solarwinds/> is in the use of this type of index with [[Big Data]] or [[data warehousing]] applications, where it is known that almost all of the table is irrelevant to the range of interest. BRIN allows the table to be queried in such cases by only retrieving blocks that ''may'' contain data of interest and excluding those which are clearly outside the range, or contain no data for this column.
Line 67 ⟶ 65:
|date=28 November 2014
|website=AXLE project
|url=http://axleproject.eu/2014/11/30/progress-on-online-upgrade/
With BRIN, the slowdown from maintaining the index is much reduced compared to B-tree.<ref>{{cite
|title=Index Overhead on a Growing Table
|date=10 October 2014
|author=Mark Wong
|newspaper=2Ndquadrant | Postgresql
|url=http://blog.2ndquadrant.com/index-overhead-growing-table/
}}</ref> Wong reports that B-tree slowed down additions to an unindexed 10GB table by 85%, but a comparable BRIN only had an overhead of 11%.<ref name="Wong, 2014" />
Line 84 ⟶ 83:
=== Dependence on table ordering ===
Multiple BRIN may be defined for different columns on a single table. However, there are restrictions.
BRIN are only efficient if the ordering of the key values follows the organisation of blocks in the storage layer.<ref name="Richard Foote, 2012, I"/><ref name="Python Sweetness"/> In the simplest case, this could require the physical ordering of the table, which is often the creation order of the rows within it, to match the key's order. Where this key is a creation date, that may be a trivial requirement.<ref name="Wong, 2015"/>{{rp|9}}
Line 90 ⟶ 89:
If the data is truly random, or if there is much churn of the key values in a 'hot' database, the assumptions underlying BRIN may break down. All blocks contain entries "of interest" and so few may be excluded early on by the BRIN range filter.
In most cases, BRIN is restricted to a single index per table. Multiple BRIN may be defined, but only one is likely to have suitable ordering. If two (or more) indexes have similar ordering behaviour, it may be possible and useful to define multiple BRIN on the same table. An obvious example is where both a creation date and a record_id column both increase [[monotonic]]ally with the record creation sequence. In other cases, the key value may not be monotonic, but provided that there is still a strong grouping within the record's physical order, BRIN is effective.
=== Exadata Storage Indexes ===
BRIN have some similarities to [[Oracle Exadata]]
|title=Smart Scans Meet Storage Indexes
|author=Arup Nanda
|date=
|journal=Oracle Magazine
|publisher=[[Oracle Corporation|Oracle]]
Line 104 ⟶ 103:
|id=1094934.1
|publisher=Oracle
}}</ref> Exadata has the strong concept of a 'storage layer' in its architecture stack. Table data is held in blocks or 'storage cells' on the storage servers. These storage cells are [[block-level storage|opaque to the storage server]] and are returned to the database engine on request, by their identifier. Previously, the database nodes must request all the storage cells in order to scan them.<ref name=Solarwinds>{{cite web
|title=Understanding Storage Indexes in Oracle Exadata
|date=2 June 2015
|url=http://logicalread.solarwinds.com/storage-indexes-oracle-exadata-mc05/#.Vpjbp27fXU8
}}</ref>
Line 115:
|url=https://richardfoote.wordpress.com/2012/10/04/exadata-storage-indexes-part-i-beginning-to-see-the-light/
}}</ref>{{efn-lr|Foote<ref name="Richard Foote, 2012, I"/> describes the Index as holding "a flag to denote whether any Nulls exist". This is probably a typo: Oracle describes them as, "negative indexes" where "they identify the areas that definitely will not contain the values"<ref name="Oracle, Exadata Storage Indexes"/> In such a case, the flag would be more clearly described as denoting either "''Only'' Nulls exist" or if "Any ''non-''Nulls exist".}}<ref>{{cite web
|title=
|author=Marc Fielding
|date=July 20, 2010
Line 129:
== Development ==
Development for PostgreSQL was carried out as part of the [[AXLE project]]
|title=European Union's
|url=
}}</ref>
== PostgreSQL ==
Implementation for PostgreSQL was first evident in 2013.<ref name="Herrera, 2013"/> BRIN appeared in release 9.5 of [[PostgreSQL]] at the start of 2016.<ref name="Python Sweetness"/><ref name="brin_indexes">{{ cite web
| date = 2014-11-07
| title = BRIN: Block Range Indexes
Line 141:
|website=PostgreSQL
| url = http://www.postgresql.org/message-id/E1XmpRL-0001Zh-Sd@gemulon.postgresql.org
|
== See also ==
Line 150:
== References ==
{{
[[Category:Database index techniques]]
|