SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
BRIN indexes on
geospatial
databases
www.2ndquadrant.com
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
~$ whoami~$ whoami
Giuseppe Broccolo, PhDGiuseppe Broccolo, PhD
PostgreSQL & PostGIS consultantPostgreSQL & PostGIS consultant
@giubro gbroccolo7
giuseppe.broccolo@2ndquadrant.it
gbroccolo gemini__81
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
Indexes & PostgreSQLIndexes & PostgreSQL
• Binary structures on disc:
– Indexing organised in nodes into 8kB pages
– Speed up data access: ~O(log N)
– High performance until the index can be contained in RAM
• Size: ~O(N)
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
Geospatial indexes in PostgreSQLGeospatial indexes in PostgreSQL
• All datatypes can be indexed in principle...
– ...just define the needed OpClass!
• Operators & Support functions
• Geospatial data can be larger than 8kB
– A single node cannot be contained into a single page
– GiST indexing allows to reduce the information that has to be
indexed compressing the PostgreSQL in-core geospatial objects
into its bounding box
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
PostGIS datatypesPostGIS datatypes
In PostGIS (since v0.6) geometry/geography are
converted into their float-precision bounding boxes
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
PostGIS datatypesPostGIS datatypes
In PostGIS (since v0.6) geometry/geography are
converted into their float-precision bounding boxes
gidx/box2df are then used as storage
datatype to populate the index’s nodes
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
GIS & BigDataGIS & BigData
LiDAR surveys
Maps of entire countries
It’s relatively easy to have to work with terabytes of geospatial data…
...can indexes be contained in RAM?
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
A new index: Block Range INdexingA new index: Block Range INdexing
– BLOCKBLOCK: set of physically adjacent 8kB pages
– RANGERANGE: boundaries of data contained in the block
– granularitygranularity: pages_per_range
• default: blocks of 128 pages
CREATE INDEX idx ON table USING brin(column) WITH (pages_per_range=10);
8kB8kB8kB8kB
S. Riggs, A. Herrera
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
BRIN - indexingBRIN - indexing
8kB8kB8kB8kB
range range range range
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
c da b
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
BRIN - indexingBRIN - indexing
8kB8kB8kB8kB
range range range range
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
c da b
a
b c
d
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
BRIN – scan executionBRIN – scan execution
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
c da b
...WHERE col<val1 AND col>val2;
BitMapIndexScan
a
b c
d
0
0
0
0
0
1
1
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
BRIN – scan executionBRIN – scan execution
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
c da b
...WHERE col<val1 AND col>val2;
BitMapHeapScan
a
b c
d
0
0
0
0
0
1
1
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
BRIN – scan executionBRIN – scan execution
8kB8kB8kB8kB
8kB8kB8kB8kB
...WHERE col<val1 AND col>val2;
“ordered” TidScan
(recheck cond)
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
BRIN – an example of execution planBRIN – an example of execution plan
QUERY PLAN
------------------------------------------------------------------
-> Bitmap Heap Scan on column (cost=113.50..26741.01 rows=10000
width=20) (actual time=6.513..3094.020 rows=2499193 loops=1)
Recheck Cond: column = value
Rows Removed by Index Recheck: 7500807
Heap Blocks: lossy=63695
-> Bitmap Index Scan on brin_index (cost=0.00..111.00 rows=10000
width=0) (actual time=6.200..6.200 rows=637440 loops=1)
Index Cond: column = value
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
BRIN support and extensibilityBRIN support and extensibility
• Two kind of support functions required in the OpClass:
– minmax key values are added following sorting criteria +
sorting operators
– inclusion key values are added following inclusion criteria +
inclusion operators
– No kNN support currently available!
• Extensibility
– provide support functions + operators to define the OpClass
http://www.postgresql.org/docs/9.5/static/brin-extensibility.html
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
BRIN support for PostGISBRIN support for PostGIS
https://github.com/dalibo/postgis/tree/for_upstream
Julien RouhaudRonan Dunklau me
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
BRIN support for PostGISBRIN support for PostGIS
NO kNN SUPPORT!!
– Different OpClass (inclusion support) for
• 2D (default), 3D, 4D geometry
• geography
• box2d/box3d (cross-operators defined in the OpFamily)
– Storage datatype: float-precision (such as in GiST)
• gidx (3D, 4D geometry)
• box2df (2D geometry, geography)
– brin_inclusion_add_value() has been redefined
– Operators: &&, @, ~ (2D) - &&& (3D, 4D)
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
Now it’s time to test our patch!Now it’s time to test our patch!
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
11stst
example: “sorted”example: “sorted” geometrygeometry pointspoints
~10M, 3D, SRID=0, distribution range: 0÷100kunits
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
11stst
example: “sorted”example: “sorted” geometrygeometry pointspoints
~10M, 3D, SRID=0, distribution range: 0÷100kunits
=# CREATE INDEX idx_gist ON points USING gist
-# (geom gist_geometry_ops_nd);
=# CREATE INDEX idx_brin_128 ON points USING brin
-# (geom brin_geometry_inclusion_ops_3d);
=# CREATE INDEX idx_brin_10 ON points USING brin
-# (geom brin_geometry_inclusion_ops_3d)
-# WITH (pages_per_range=10);
BRIN(128)/GiST 1/2000
BRIN(10)/GiST 1/1000
BRIN(128)/GiST 1/30
BRIN(10)/GiST 1/20
Sizes
Building
times
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
11stst
example: “sorted”example: “sorted” geometrygeometry pointspoints
~10M, 3D, SRID=0, distribution range: 0÷100kunits
=# SELECT * FROM points
-# WHERE ‘BOX3D(10. 10. 10., 12., 12., 12.)’::box3d &&& geom;
BRIN(128)/GiST 50/1
BRIN(10)/GiST 6/1
BRIN(128)/SeqScan 1/60
BRIN(10)/SeqScan 1/350
Execution times
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
22ndnd
example: “unsorted”example: “unsorted” geometrygeometry pointspoints
~10M, 3D, SRID=0, distribution range: 0÷100kunits
=# CREATE TABLE unsorted_points AS
-# SELECT * FROM points ORDER BY random();
=# SELECT * FROM unsorted_points
-# WHERE ‘BOX3D(10. 10. 10., 12., 12., 12.)’::box3d &&& geom;
BRIN(128)/GiST 2800/1
BRIN(10)/GiST 400/1
BRIN(128)/SeqScan 1/1
BRIN(10)/SeqScan 1/12
Execution times
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
22ndnd
example: “unsorted”example: “unsorted” geometrygeometry pointspoints
=# CREATE EXTENSION pageinspect;
=# SELECT blknum, value FROM brin_page_items(get_raw_page('idx_brin_128', 2), 'idx_brin_128')
-# LIMIT 5;
blknum | value
--------+------------------------------------------------------------------------
0 | {GIDX( 1.11394846439 1.64980053902 1.11335003376, 99982.2578125 99982.640625
99982.1171875 ) .. f .. f}
128 | {GIDX( 0.224781364202 0.184096381068 0.798862099648, 99995.859375 99995.171875
99995.0390625 ) .. f .. f}
256 | {GIDX( 6.25802087784 6.50119876862 6.8031873703, 99993.15625 99993.8203125
99993.2109375 ) .. f .. f}
384 | {GIDX( 1.9203556776 1.11907613277 1.55043530464, 99995.421875 99995.234375
99995.421875 ) .. f .. f}
512 | {GIDX( 3.44181084633 3.4120452404 3.41762590408, 99996.3125 99996.7109375 99996.59375
) .. f .. f}
(5 rows)
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
A real case: earthquakes in the USA in 2016A real case: earthquakes in the USA in 2016
http://earthquake.usgs.gov/http://earthquake.usgs.gov/ ~100k lat/lon WGS84 points
(earthquakes in the world)
~1M SRID 102008 linestrings
(railways in the west side,
not Colorado)
http://www.openstreetmap.org/http://www.openstreetmap.org/
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
A real case: earthquakes in the USA in 2016A real case: earthquakes in the USA in 2016
http://earthquake.usgs.gov/http://earthquake.usgs.gov/ ~100k lat/lon WGS84 points
(earthquakes in the world)
~1M SRID 102008 linestrings
(railways in the west side,
not Colorado)
Which railway was closeWhich railway was close
(<10km) to an earthquake(<10km) to an earthquake
epicenter?epicenter?
http://www.openstreetmap.org/http://www.openstreetmap.org/
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
A real case: earthquakes in the USA in 2016A real case: earthquakes in the USA in 2016
=# CREATE INDEX idx_rl_gist ON westrailways USING gist
-# (ST_Buffer(GEOGRAPHY(ST_Trasform(geom), 4326), 10000));
=# CREATE INDEX idx_eq_brin ON worldearthquakes USING gist (coord);
BRIN/GiST Sizes ~1/100
BRIN/GiST Times ~1/200
=# CREATE INDEX idx_rl_brin ON westrailways USING brin
-# (ST_Buffer(GEOGRAPHY(ST_Trasform(geom), 4326), 10000))
-# WITH (pages_per_range=10);
=# CREATE INDEX idx_eq_brin ON worldearthquakes USING brin (coord)
-# WITH (pages_per_range=10);
BRINBRIN
GiSTGiST
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
A real case: earthquakes in the USA in 2016A real case: earthquakes in the USA in 2016
=# WITH us_eq AS (
-# SELECT coord FROM world
-# WHERE coord && ‘BOX2D(-126.90 49.73, -65.83 24.73)’::box2d
-# ) SELECT * FROM railways r, us_eq u
-# WHERE ST_Buffer(GEOGRAPHY(ST_Trasform(geom), 4326), 10000) && u.coord;
• without indexes: ~60s
• with GiST: ~20ms
• with BRIN: ~400ms
...so, is GIS data “naturally” ordered?
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
It’s not a matter of “natural” order...It’s not a matter of “natural” order...
Recheck Cond: (ST_Buffer(GEOGRAPHY(ST_Trasform(geom), 4326), 10000) && u.coord)
Rows Removed by Index Recheck: 10546
Heap Blocks: lossy=512
• both indexes are used: bitmapindexscan/bitmapheapscan
– indexes pages has to be read many times!
• the query plan is “complex” - more “recheck” nodes in the plan
Recheck Cond: (ST_Buffer(GEOGRAPHY(ST_Trasform(geom), 4326), 10000) && u.coord)
Rows Removed by Index Recheck: 5424
Heap Blocks: lossy=42
BRINBRIN
GiSTGiST
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
...what about...what about INSERTINSERT’s?’s?
INSERT INTO railways SELECT * FROM colorado_railways;
GiST 147ms
BRIN (10) 79ms
BRIN (128) 63ms
No indexes 23ms
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
A really good testbed: LiDAR dataA really good testbed: LiDAR data
PostgreSQL extension for LiDAR data: pg_pointcloud
GiST performances:
– storage: 1TB RAID1, RAM 16GB, 8 CPU @3.3GHz,
PostgreSQL9.3
– index size ~O(table size)
– Index was used:
• up to ~300M points in bbox inclusion searches
• up to ~10M points in kNN searches
LiDAR size: ~O(109
÷1011
) → less than 10% can be properly indexed!
http://www.slideshare.net/GiuseppeBroccolo/gbroccolo-foss4-geugeodbindex
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
Is the patch compatible withIs the patch compatible with pg_pointcloudpg_pointcloud??
1.6TB, ~250G points in ~560M patches1.6TB, ~250G points in ~560M patches
44thth
May, room 302C, 5:20PMMay, room 302C, 5:20PM
Here just a summary:
– BRIN/GiST ~O(10MB) not ~O(10GB)
– BRIN/GiST ~O(1h) not ~O(1day)
– bbox inclusion searches:
• GiST = 20x faster than BRIN
• BRIN = 200x faster than SeqScan
• BRIN work better with low selectivity
queries
– All BRIN index pages can be contained in RAM
– SELECTs on more than ~50% of the dataset through BRIN scan
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
ConclusionsConclusions
• BRINs can be successfully used in geo DB based on PostgreSQL
– totally support PostGIS datatype
• A patch almost ready for the next PostGIS release (2.3.0)
– easier indexes maintenance, low indexing time, low impact on concurrent
INSERTs
– less specific than GiST...but not to much!
• Really small indexes!
– GiST performances drop as well as it cannot be totally contained in RAM
– BRIN can be successfully used in LiDAR dataset, at least for bbox inclusion searches
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
Special thanks to...Special thanks to...
• Julien Rouhaud
• Ronan Dunklau
•
•
•
• Alvaro Herrera
• Emre Hesegeli
• ...and to 2ndQuadrant!
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PGDay@FOSS4G.NA 2016
Raleigh, NC
3rd
May 2016
Creative Commons license
This work is licensed under a Creative Commons
Attribution-ShareAlike 4.0 International License
http://creativecommons.org/licenses/by-nc-sa/2.5/it/
© 2016 2ndQuadrant Italia – http://www.2ndquadrant.it

Weitere ähnliche Inhalte

Ähnlich wie BRIN indexes on geospatial databases - FOSS4G.NA 2016

gbroccolo - Use of Indexes on geospatial databases with PostgreSQL - FOSS4G.E...
gbroccolo - Use of Indexes on geospatial databases with PostgreSQL - FOSS4G.E...gbroccolo - Use of Indexes on geospatial databases with PostgreSQL - FOSS4G.E...
gbroccolo - Use of Indexes on geospatial databases with PostgreSQL - FOSS4G.E...Giuseppe Broccolo
 
GBroccolo JRouhaud pgconfeu2016_brin4postgis
GBroccolo JRouhaud pgconfeu2016_brin4postgisGBroccolo JRouhaud pgconfeu2016_brin4postgis
GBroccolo JRouhaud pgconfeu2016_brin4postgisGiuseppe Broccolo
 
This week in Neo4j - 28th October 2017
This week in Neo4j - 28th October 2017This week in Neo4j - 28th October 2017
This week in Neo4j - 28th October 2017Neo4j
 
Don't panic! - Postgres introduction
Don't panic! - Postgres introductionDon't panic! - Postgres introduction
Don't panic! - Postgres introductionFederico Campoli
 
a look at the postgresql engine
a look at the postgresql enginea look at the postgresql engine
a look at the postgresql engineFederico Campoli
 
Machine Learning Applications
Machine Learning ApplicationsMachine Learning Applications
Machine Learning ApplicationsSimplyInsight
 
Gbroccolo pgconfeu2016 pgnfs
Gbroccolo pgconfeu2016 pgnfsGbroccolo pgconfeu2016 pgnfs
Gbroccolo pgconfeu2016 pgnfsGiuseppe Broccolo
 

Ähnlich wie BRIN indexes on geospatial databases - FOSS4G.NA 2016 (9)

gbroccolo - Use of Indexes on geospatial databases with PostgreSQL - FOSS4G.E...
gbroccolo - Use of Indexes on geospatial databases with PostgreSQL - FOSS4G.E...gbroccolo - Use of Indexes on geospatial databases with PostgreSQL - FOSS4G.E...
gbroccolo - Use of Indexes on geospatial databases with PostgreSQL - FOSS4G.E...
 
GBroccolo JRouhaud pgconfeu2016_brin4postgis
GBroccolo JRouhaud pgconfeu2016_brin4postgisGBroccolo JRouhaud pgconfeu2016_brin4postgis
GBroccolo JRouhaud pgconfeu2016_brin4postgis
 
This week in Neo4j - 28th October 2017
This week in Neo4j - 28th October 2017This week in Neo4j - 28th October 2017
This week in Neo4j - 28th October 2017
 
SuperAGILE Data Analysis System
SuperAGILE Data Analysis SystemSuperAGILE Data Analysis System
SuperAGILE Data Analysis System
 
Don't panic! - Postgres introduction
Don't panic! - Postgres introductionDon't panic! - Postgres introduction
Don't panic! - Postgres introduction
 
a look at the postgresql engine
a look at the postgresql enginea look at the postgresql engine
a look at the postgresql engine
 
Armando Benitez -- Data x Desing
Armando Benitez -- Data x DesingArmando Benitez -- Data x Desing
Armando Benitez -- Data x Desing
 
Machine Learning Applications
Machine Learning ApplicationsMachine Learning Applications
Machine Learning Applications
 
Gbroccolo pgconfeu2016 pgnfs
Gbroccolo pgconfeu2016 pgnfsGbroccolo pgconfeu2016 pgnfs
Gbroccolo pgconfeu2016 pgnfs
 

Kürzlich hochgeladen

一比一原版纽卡斯尔大学毕业证成绩单如何办理
一比一原版纽卡斯尔大学毕业证成绩单如何办理一比一原版纽卡斯尔大学毕业证成绩单如何办理
一比一原版纽卡斯尔大学毕业证成绩单如何办理cyebo
 
How I opened a fake bank account and didn't go to prison
How I opened a fake bank account and didn't go to prisonHow I opened a fake bank account and didn't go to prison
How I opened a fake bank account and didn't go to prisonPayment Village
 
Formulas dax para power bI de microsoft.pdf
Formulas dax para power bI de microsoft.pdfFormulas dax para power bI de microsoft.pdf
Formulas dax para power bI de microsoft.pdfRobertoOcampo24
 
The Significance of Transliteration Enhancing
The Significance of Transliteration EnhancingThe Significance of Transliteration Enhancing
The Significance of Transliteration Enhancingmohamed Elzalabany
 
Exploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptxExploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptxDilipVasan
 
2024 Q2 Orange County (CA) Tableau User Group Meeting
2024 Q2 Orange County (CA) Tableau User Group Meeting2024 Q2 Orange County (CA) Tableau User Group Meeting
2024 Q2 Orange County (CA) Tableau User Group MeetingAlison Pitt
 
Easy and simple project file on mp online
Easy and simple project file on mp onlineEasy and simple project file on mp online
Easy and simple project file on mp onlinebalibahu1313
 
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...Valters Lauzums
 
Atlantic Grupa Case Study (Mintec Data AI)
Atlantic Grupa Case Study (Mintec Data AI)Atlantic Grupa Case Study (Mintec Data AI)
Atlantic Grupa Case Study (Mintec Data AI)Jon Hansen
 
Artificial_General_Intelligence__storm_gen_article.pdf
Artificial_General_Intelligence__storm_gen_article.pdfArtificial_General_Intelligence__storm_gen_article.pdf
Artificial_General_Intelligence__storm_gen_article.pdfscitechtalktv
 
一比一原版西悉尼大学毕业证成绩单如何办理
一比一原版西悉尼大学毕业证成绩单如何办理一比一原版西悉尼大学毕业证成绩单如何办理
一比一原版西悉尼大学毕业证成绩单如何办理pyhepag
 
basics of data science with application areas.pdf
basics of data science with application areas.pdfbasics of data science with application areas.pdf
basics of data science with application areas.pdfvyankatesh1
 
Generative AI for Trailblazers_ Unlock the Future of AI.pdf
Generative AI for Trailblazers_ Unlock the Future of AI.pdfGenerative AI for Trailblazers_ Unlock the Future of AI.pdf
Generative AI for Trailblazers_ Unlock the Future of AI.pdfEmmanuel Dauda
 
一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理pyhepag
 
2024 Q1 Tableau User Group Leader Quarterly Call
2024 Q1 Tableau User Group Leader Quarterly Call2024 Q1 Tableau User Group Leader Quarterly Call
2024 Q1 Tableau User Group Leader Quarterly Calllward7
 
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理pyhepag
 
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...Amil baba
 

Kürzlich hochgeladen (20)

一比一原版纽卡斯尔大学毕业证成绩单如何办理
一比一原版纽卡斯尔大学毕业证成绩单如何办理一比一原版纽卡斯尔大学毕业证成绩单如何办理
一比一原版纽卡斯尔大学毕业证成绩单如何办理
 
How I opened a fake bank account and didn't go to prison
How I opened a fake bank account and didn't go to prisonHow I opened a fake bank account and didn't go to prison
How I opened a fake bank account and didn't go to prison
 
Formulas dax para power bI de microsoft.pdf
Formulas dax para power bI de microsoft.pdfFormulas dax para power bI de microsoft.pdf
Formulas dax para power bI de microsoft.pdf
 
The Significance of Transliteration Enhancing
The Significance of Transliteration EnhancingThe Significance of Transliteration Enhancing
The Significance of Transliteration Enhancing
 
Exploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptxExploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptx
 
2024 Q2 Orange County (CA) Tableau User Group Meeting
2024 Q2 Orange County (CA) Tableau User Group Meeting2024 Q2 Orange County (CA) Tableau User Group Meeting
2024 Q2 Orange County (CA) Tableau User Group Meeting
 
Easy and simple project file on mp online
Easy and simple project file on mp onlineEasy and simple project file on mp online
Easy and simple project file on mp online
 
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
Data Analytics for Digital Marketing Lecture for Advanced Digital & Social Me...
 
Atlantic Grupa Case Study (Mintec Data AI)
Atlantic Grupa Case Study (Mintec Data AI)Atlantic Grupa Case Study (Mintec Data AI)
Atlantic Grupa Case Study (Mintec Data AI)
 
Machine Learning for Accident Severity Prediction
Machine Learning for Accident Severity PredictionMachine Learning for Accident Severity Prediction
Machine Learning for Accident Severity Prediction
 
Slip-and-fall Injuries: Top Workers' Comp Claims
Slip-and-fall Injuries: Top Workers' Comp ClaimsSlip-and-fall Injuries: Top Workers' Comp Claims
Slip-and-fall Injuries: Top Workers' Comp Claims
 
Artificial_General_Intelligence__storm_gen_article.pdf
Artificial_General_Intelligence__storm_gen_article.pdfArtificial_General_Intelligence__storm_gen_article.pdf
Artificial_General_Intelligence__storm_gen_article.pdf
 
一比一原版西悉尼大学毕业证成绩单如何办理
一比一原版西悉尼大学毕业证成绩单如何办理一比一原版西悉尼大学毕业证成绩单如何办理
一比一原版西悉尼大学毕业证成绩单如何办理
 
basics of data science with application areas.pdf
basics of data science with application areas.pdfbasics of data science with application areas.pdf
basics of data science with application areas.pdf
 
Generative AI for Trailblazers_ Unlock the Future of AI.pdf
Generative AI for Trailblazers_ Unlock the Future of AI.pdfGenerative AI for Trailblazers_ Unlock the Future of AI.pdf
Generative AI for Trailblazers_ Unlock the Future of AI.pdf
 
一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理一比一原版阿德莱德大学毕业证成绩单如何办理
一比一原版阿德莱德大学毕业证成绩单如何办理
 
Abortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotec
Abortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotecAbortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotec
Abortion pills in Dammam Saudi Arabia// +966572737505 // buy cytotec
 
2024 Q1 Tableau User Group Leader Quarterly Call
2024 Q1 Tableau User Group Leader Quarterly Call2024 Q1 Tableau User Group Leader Quarterly Call
2024 Q1 Tableau User Group Leader Quarterly Call
 
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
一比一原版(Monash毕业证书)莫纳什大学毕业证成绩单如何办理
 
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
 

BRIN indexes on geospatial databases - FOSS4G.NA 2016

  • 1. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 BRIN indexes on geospatial databases www.2ndquadrant.com
  • 2. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 ~$ whoami~$ whoami Giuseppe Broccolo, PhDGiuseppe Broccolo, PhD PostgreSQL & PostGIS consultantPostgreSQL & PostGIS consultant @giubro gbroccolo7 giuseppe.broccolo@2ndquadrant.it gbroccolo gemini__81
  • 3. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 Indexes & PostgreSQLIndexes & PostgreSQL • Binary structures on disc: – Indexing organised in nodes into 8kB pages – Speed up data access: ~O(log N) – High performance until the index can be contained in RAM • Size: ~O(N)
  • 4. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 Geospatial indexes in PostgreSQLGeospatial indexes in PostgreSQL • All datatypes can be indexed in principle... – ...just define the needed OpClass! • Operators & Support functions • Geospatial data can be larger than 8kB – A single node cannot be contained into a single page – GiST indexing allows to reduce the information that has to be indexed compressing the PostgreSQL in-core geospatial objects into its bounding box
  • 5. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 PostGIS datatypesPostGIS datatypes In PostGIS (since v0.6) geometry/geography are converted into their float-precision bounding boxes
  • 6. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 PostGIS datatypesPostGIS datatypes In PostGIS (since v0.6) geometry/geography are converted into their float-precision bounding boxes gidx/box2df are then used as storage datatype to populate the index’s nodes
  • 7. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 GIS & BigDataGIS & BigData LiDAR surveys Maps of entire countries It’s relatively easy to have to work with terabytes of geospatial data… ...can indexes be contained in RAM?
  • 8. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 A new index: Block Range INdexingA new index: Block Range INdexing – BLOCKBLOCK: set of physically adjacent 8kB pages – RANGERANGE: boundaries of data contained in the block – granularitygranularity: pages_per_range • default: blocks of 128 pages CREATE INDEX idx ON table USING brin(column) WITH (pages_per_range=10); 8kB8kB8kB8kB S. Riggs, A. Herrera
  • 9. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 BRIN - indexingBRIN - indexing 8kB8kB8kB8kB range range range range 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB c da b
  • 10. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 BRIN - indexingBRIN - indexing 8kB8kB8kB8kB range range range range 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB c da b a b c d
  • 11. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 BRIN – scan executionBRIN – scan execution 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB c da b ...WHERE col<val1 AND col>val2; BitMapIndexScan a b c d 0 0 0 0 0 1 1
  • 12. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 BRIN – scan executionBRIN – scan execution 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB c da b ...WHERE col<val1 AND col>val2; BitMapHeapScan a b c d 0 0 0 0 0 1 1
  • 13. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 BRIN – scan executionBRIN – scan execution 8kB8kB8kB8kB 8kB8kB8kB8kB ...WHERE col<val1 AND col>val2; “ordered” TidScan (recheck cond)
  • 14. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 BRIN – an example of execution planBRIN – an example of execution plan QUERY PLAN ------------------------------------------------------------------ -> Bitmap Heap Scan on column (cost=113.50..26741.01 rows=10000 width=20) (actual time=6.513..3094.020 rows=2499193 loops=1) Recheck Cond: column = value Rows Removed by Index Recheck: 7500807 Heap Blocks: lossy=63695 -> Bitmap Index Scan on brin_index (cost=0.00..111.00 rows=10000 width=0) (actual time=6.200..6.200 rows=637440 loops=1) Index Cond: column = value
  • 15. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 BRIN support and extensibilityBRIN support and extensibility • Two kind of support functions required in the OpClass: – minmax key values are added following sorting criteria + sorting operators – inclusion key values are added following inclusion criteria + inclusion operators – No kNN support currently available! • Extensibility – provide support functions + operators to define the OpClass http://www.postgresql.org/docs/9.5/static/brin-extensibility.html
  • 16. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 BRIN support for PostGISBRIN support for PostGIS https://github.com/dalibo/postgis/tree/for_upstream Julien RouhaudRonan Dunklau me
  • 17. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 BRIN support for PostGISBRIN support for PostGIS NO kNN SUPPORT!! – Different OpClass (inclusion support) for • 2D (default), 3D, 4D geometry • geography • box2d/box3d (cross-operators defined in the OpFamily) – Storage datatype: float-precision (such as in GiST) • gidx (3D, 4D geometry) • box2df (2D geometry, geography) – brin_inclusion_add_value() has been redefined – Operators: &&, @, ~ (2D) - &&& (3D, 4D)
  • 18. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 Now it’s time to test our patch!Now it’s time to test our patch!
  • 19. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 11stst example: “sorted”example: “sorted” geometrygeometry pointspoints ~10M, 3D, SRID=0, distribution range: 0÷100kunits
  • 20. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 11stst example: “sorted”example: “sorted” geometrygeometry pointspoints ~10M, 3D, SRID=0, distribution range: 0÷100kunits =# CREATE INDEX idx_gist ON points USING gist -# (geom gist_geometry_ops_nd); =# CREATE INDEX idx_brin_128 ON points USING brin -# (geom brin_geometry_inclusion_ops_3d); =# CREATE INDEX idx_brin_10 ON points USING brin -# (geom brin_geometry_inclusion_ops_3d) -# WITH (pages_per_range=10); BRIN(128)/GiST 1/2000 BRIN(10)/GiST 1/1000 BRIN(128)/GiST 1/30 BRIN(10)/GiST 1/20 Sizes Building times
  • 21. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 11stst example: “sorted”example: “sorted” geometrygeometry pointspoints ~10M, 3D, SRID=0, distribution range: 0÷100kunits =# SELECT * FROM points -# WHERE ‘BOX3D(10. 10. 10., 12., 12., 12.)’::box3d &&& geom; BRIN(128)/GiST 50/1 BRIN(10)/GiST 6/1 BRIN(128)/SeqScan 1/60 BRIN(10)/SeqScan 1/350 Execution times
  • 22. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 22ndnd example: “unsorted”example: “unsorted” geometrygeometry pointspoints ~10M, 3D, SRID=0, distribution range: 0÷100kunits =# CREATE TABLE unsorted_points AS -# SELECT * FROM points ORDER BY random(); =# SELECT * FROM unsorted_points -# WHERE ‘BOX3D(10. 10. 10., 12., 12., 12.)’::box3d &&& geom; BRIN(128)/GiST 2800/1 BRIN(10)/GiST 400/1 BRIN(128)/SeqScan 1/1 BRIN(10)/SeqScan 1/12 Execution times
  • 23. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 22ndnd example: “unsorted”example: “unsorted” geometrygeometry pointspoints =# CREATE EXTENSION pageinspect; =# SELECT blknum, value FROM brin_page_items(get_raw_page('idx_brin_128', 2), 'idx_brin_128') -# LIMIT 5; blknum | value --------+------------------------------------------------------------------------ 0 | {GIDX( 1.11394846439 1.64980053902 1.11335003376, 99982.2578125 99982.640625 99982.1171875 ) .. f .. f} 128 | {GIDX( 0.224781364202 0.184096381068 0.798862099648, 99995.859375 99995.171875 99995.0390625 ) .. f .. f} 256 | {GIDX( 6.25802087784 6.50119876862 6.8031873703, 99993.15625 99993.8203125 99993.2109375 ) .. f .. f} 384 | {GIDX( 1.9203556776 1.11907613277 1.55043530464, 99995.421875 99995.234375 99995.421875 ) .. f .. f} 512 | {GIDX( 3.44181084633 3.4120452404 3.41762590408, 99996.3125 99996.7109375 99996.59375 ) .. f .. f} (5 rows)
  • 24. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 A real case: earthquakes in the USA in 2016A real case: earthquakes in the USA in 2016 http://earthquake.usgs.gov/http://earthquake.usgs.gov/ ~100k lat/lon WGS84 points (earthquakes in the world) ~1M SRID 102008 linestrings (railways in the west side, not Colorado) http://www.openstreetmap.org/http://www.openstreetmap.org/
  • 25. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 A real case: earthquakes in the USA in 2016A real case: earthquakes in the USA in 2016 http://earthquake.usgs.gov/http://earthquake.usgs.gov/ ~100k lat/lon WGS84 points (earthquakes in the world) ~1M SRID 102008 linestrings (railways in the west side, not Colorado) Which railway was closeWhich railway was close (<10km) to an earthquake(<10km) to an earthquake epicenter?epicenter? http://www.openstreetmap.org/http://www.openstreetmap.org/
  • 26. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 A real case: earthquakes in the USA in 2016A real case: earthquakes in the USA in 2016 =# CREATE INDEX idx_rl_gist ON westrailways USING gist -# (ST_Buffer(GEOGRAPHY(ST_Trasform(geom), 4326), 10000)); =# CREATE INDEX idx_eq_brin ON worldearthquakes USING gist (coord); BRIN/GiST Sizes ~1/100 BRIN/GiST Times ~1/200 =# CREATE INDEX idx_rl_brin ON westrailways USING brin -# (ST_Buffer(GEOGRAPHY(ST_Trasform(geom), 4326), 10000)) -# WITH (pages_per_range=10); =# CREATE INDEX idx_eq_brin ON worldearthquakes USING brin (coord) -# WITH (pages_per_range=10); BRINBRIN GiSTGiST
  • 27. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 A real case: earthquakes in the USA in 2016A real case: earthquakes in the USA in 2016 =# WITH us_eq AS ( -# SELECT coord FROM world -# WHERE coord && ‘BOX2D(-126.90 49.73, -65.83 24.73)’::box2d -# ) SELECT * FROM railways r, us_eq u -# WHERE ST_Buffer(GEOGRAPHY(ST_Trasform(geom), 4326), 10000) && u.coord; • without indexes: ~60s • with GiST: ~20ms • with BRIN: ~400ms ...so, is GIS data “naturally” ordered?
  • 28. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 It’s not a matter of “natural” order...It’s not a matter of “natural” order... Recheck Cond: (ST_Buffer(GEOGRAPHY(ST_Trasform(geom), 4326), 10000) && u.coord) Rows Removed by Index Recheck: 10546 Heap Blocks: lossy=512 • both indexes are used: bitmapindexscan/bitmapheapscan – indexes pages has to be read many times! • the query plan is “complex” - more “recheck” nodes in the plan Recheck Cond: (ST_Buffer(GEOGRAPHY(ST_Trasform(geom), 4326), 10000) && u.coord) Rows Removed by Index Recheck: 5424 Heap Blocks: lossy=42 BRINBRIN GiSTGiST
  • 29. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 ...what about...what about INSERTINSERT’s?’s? INSERT INTO railways SELECT * FROM colorado_railways; GiST 147ms BRIN (10) 79ms BRIN (128) 63ms No indexes 23ms
  • 30. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 A really good testbed: LiDAR dataA really good testbed: LiDAR data PostgreSQL extension for LiDAR data: pg_pointcloud GiST performances: – storage: 1TB RAID1, RAM 16GB, 8 CPU @3.3GHz, PostgreSQL9.3 – index size ~O(table size) – Index was used: • up to ~300M points in bbox inclusion searches • up to ~10M points in kNN searches LiDAR size: ~O(109 ÷1011 ) → less than 10% can be properly indexed! http://www.slideshare.net/GiuseppeBroccolo/gbroccolo-foss4-geugeodbindex
  • 31. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 Is the patch compatible withIs the patch compatible with pg_pointcloudpg_pointcloud?? 1.6TB, ~250G points in ~560M patches1.6TB, ~250G points in ~560M patches 44thth May, room 302C, 5:20PMMay, room 302C, 5:20PM Here just a summary: – BRIN/GiST ~O(10MB) not ~O(10GB) – BRIN/GiST ~O(1h) not ~O(1day) – bbox inclusion searches: • GiST = 20x faster than BRIN • BRIN = 200x faster than SeqScan • BRIN work better with low selectivity queries – All BRIN index pages can be contained in RAM – SELECTs on more than ~50% of the dataset through BRIN scan
  • 32. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 ConclusionsConclusions • BRINs can be successfully used in geo DB based on PostgreSQL – totally support PostGIS datatype • A patch almost ready for the next PostGIS release (2.3.0) – easier indexes maintenance, low indexing time, low impact on concurrent INSERTs – less specific than GiST...but not to much! • Really small indexes! – GiST performances drop as well as it cannot be totally contained in RAM – BRIN can be successfully used in LiDAR dataset, at least for bbox inclusion searches
  • 33. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 Special thanks to...Special thanks to... • Julien Rouhaud • Ronan Dunklau • • • • Alvaro Herrera • Emre Hesegeli • ...and to 2ndQuadrant!
  • 34. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PGDay@FOSS4G.NA 2016 Raleigh, NC 3rd May 2016 Creative Commons license This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License http://creativecommons.org/licenses/by-nc-sa/2.5/it/ © 2016 2ndQuadrant Italia – http://www.2ndquadrant.it