SlideShare a Scribd company logo
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
June, 14th
2016
BRIN indexes on
geospatial
databases
www.2ndquadrant.com
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
~$ 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
Indexes & PostgreSQLIndexes & PostgreSQL
• Binary structures on disc:
– Indexing organised in nodes into 8kB pages
– Nodes point to table rows
• 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
Geospatial indexes in PostgreSQLGeospatial indexes in PostgreSQL
• All datatypes can be indexed in principle...
– ...just define the needed Operator Class!
• Operators & support functions
– ...define how the data has to be stored into the index nodes
• Geospatial data:
– can be larger than 8kB
– Is generally a varlena
– a single node cannot be contained into a single page
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PostGIS datatypes & GiST indexingPostGIS datatypes & GiST indexing
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
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
A new index: Block Range Indexing (PG 9.5)A new index: Block Range Indexing (PG 9.5)
CREATE INDEX idx ON table
USING brin(column) WITH (pages_per_range=10);
data must be physically sorted on disk!
index node → row
index node → block
less specific than GiST!
Really small!
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
(S. Riggs, A. Herrera)
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
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
BRIN support for PostGISBRIN support for PostGIS
NO kNN SUPPORT!!
– Different OpClass 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)
– Operators: &&, @, ~ (2D) - &&& (3D, 4D)
8kB8kB8kB8kB
8kB8kB8kB8kB
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
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
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
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
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
...what about...what about INSERTINSERT’s?’s?
INSERT INTO points
SELECT ST_MakePoint(a, a, a)
FROM generate_series(1, 1000) AS f(a);
GiST 6 times than insertions without index
BRIN (10) 3 times than insertions without index
BRIN (128) 2 times than insertions without index
...blocks could be “not sorted” anymore!
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
Manage LiDAR
data with
PostgreSQL
is it possible?
Is the relational approach valid for point clouds?Is the relational approach valid for point clouds?
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
PostgreSQL & LiDARPostgreSQL & LiDAR
• PostgreSQL is a relational DBMS with an extension for LiDAR data:
pg_pointcloud
• Part of the OpenGeo suite, completely compatible with PostGIS
– two new datatype: pcpoint, pcpatch (compressed set of points)
• N points (with all attributes from the survey) → 1 patch → 1 record
– compatible with PDAL drivers to import data directly from .las
32b 32b 32b 16b
https://github.com/pgpointcloud/pointcloud
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
Relational approach to LiDAR data with PGRelational approach to LiDAR data with PG
• GiST indexing in PostGIS
• 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
) → few % can be properly indexed!
http://www.slideshare.net/GiuseppeBroccolo/gbroccolo-foss4-geugeodbindex
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
The LiDAR dataset: the ahn2 projectThe LiDAR dataset: the ahn2 project
• 3D point cloud, coverage: almost the whole Netherlands
– EPSG: 28992, ~8 points/m2
• 1.6TB, ~250G points in ~560M patches (compression: ~10x)
– PDAL driver – filter.chipper
• available RAM: 16GB
• the point structure:
X Y Z scan LAS time RGB chipper
32b 32b 32b 40b 16b 64b 48b 32b
the “indexed” part (can be converted to PostGIS datatype)
(thanks to Tom Van Tilburg)
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
Typical searches on ahn2 -Typical searches on ahn2 - x3d_viewerx3d_viewer
• Intersection with a polygon (PostGIS)
– the part that lasts longer – need indexes here!
• Patch “explosion” + NN sorting (pg_PointCloud+PostGIS)
• constrained Delaunay Triangulation (SFCGAL)
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
WITH patches AS (
SELECT patches FROM ahn2
WHERE patches && ST_GeomFromText(‘POLYGON(...)’)
), points AS (
SELECT ST_Explode(patches) AS points
FROM patches
), sorted_points AS (
SELECT points,
ST_DumpPoints(ST_GeomFromText(‘POLYGON(...)’))).geom AS poly_pt
FROM points ORDER BY points <#> poly_pt LIMIT 1;
), sel AS (
SELECT points FROM sorted_points
WHERE points && ST_GeomFromText(‘POLYGON(...)’)
)
SELECT ST_Dump(ST_Triangulate2DZ(ST_Collect(points))) FROM sel;
All in the DB & just with one query!All in the DB & just with one query!
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
patches && polygons - GiST performancepatches && polygons - GiST performance
GiST 2.5 days
GiST 29GB
index building
index size
polygon
size
timing
~O(10m) ~20ms
~O(100m) ~60ms
~O(1Km) ~3s
~O(10km) hours
searches based on GiST
index not contained in
RAM anymore
(~5G points → ~3%)
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
patches && polygons - BRIN performancepatches && polygons - BRIN performance
BRIN 4 h BRIN 15MB
index building
polygon
size
timing
~O(m) ~150s
searches based on BRIN
index size
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
patches && polygons - BRIN performancepatches && polygons - BRIN performance
BRIN 5 h BRIN 14MB
index building
polygon
size
timing
~O(m) ~150s
searches based on BRIN
How data was inserted...
LASLASLASLASLASLAS
chipper
chipper
chipper
PDAL driver
(parallel processes)
ahn2
index size
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
Spatial sorting of a LiDAR datasetSpatial sorting of a LiDAR dataset
CREATE INDEX patch_geohash ON ahn2
USING btree (ST_GeoHash(ST_Transform(Geometry(patch), 4326), 20));
CLUSTER ahn2 USING patch_geohash;
Morton order [http://geohash.org/]
Need more than 2X table size free space
Relatively fast!
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
Spatial sorting of a LiDAR datasetSpatial sorting of a LiDAR dataset
CREATE TABLE ahn2_sorted ON ahn2 AS
SELECT * FROM ahn2
ORDER BY ST_GeoHash(ST_Transform(Geometry(patch), 4326), 10)
COLLATE “C”;
Morton order [http://geohash.org/]
Just need size for a second table
Slower than clustering using the index!
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
Spatial sorting of a LiDAR datasetSpatial sorting of a LiDAR dataset
CREATE TABLE ahn2_sorted ON ahn2 AS
SELECT * FROM ahn2
ORDER BY ST_GeoHash(ST_Transform(Geometry(patch), 4326), 10)
COLLATE “C”;
Morton order [http://geohash.org/]
Just need size for a second table
Slower than clustering using the index!
45 hours
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
patches && polygons – BRIN performancepatches && polygons – BRIN performance
polygon
size
BRIN
timing
GiST
timing
~O(10m) ~380ms ~20ms
~O(100m) ~400ms ~60ms
~O(1Km) ~2.7s ~3s
~O(10km) ~4.7s hours
• After sorting: 150s→380ms
• GiST X20 faster than BRIN [r~O(10m)]
– BRIN X200 faster than SeqScan
• BRIN X1000 faster than SeqScan [r~O(100m)]
•
• BRIN ~ GiST [r~O(1Km)]
• Just BRIN is used for searches r>1km
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
is the drop in performance acceptable?is the drop in performance acceptable?
BRIN searches = x20 GiST searches
= x10÷x100 GiST searches
= x10÷x100 GiST searches
patch explosion
+
NN sorting
constrained
triangulation
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
the future of the project...add kNN supportthe future of the project...add kNN support
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
8kB8kB8kB8kB
k
get blocks gradually included within the k parameter, as already made
in GiST with single tuples
WIP…sponsorships are welcome!
ORDER BY geoms <-> point
LIMIT N
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
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
• Can be relational approach to LiDAR data valid with PostgreSQL?
– Yes, at least for bbox inclusion searches
– make sure that data has the same sequentiality of .las
2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it
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

More Related Content

Viewers also liked

Curriculum Attore Maurizio Panfilo con foto
Curriculum Attore Maurizio Panfilo con fotoCurriculum Attore Maurizio Panfilo con foto
Curriculum Attore Maurizio Panfilo con fotoMaurizio Panfilo
 
Photo shoot
Photo shootPhoto shoot
Photo shoot
ayakhaireh1
 
Was ist das für 1 Omni-Channel?
Was ist das für 1 Omni-Channel? Was ist das für 1 Omni-Channel?
Was ist das für 1 Omni-Channel?
Torben Haagh
 
Unit 5 interactive document
Unit 5 interactive documentUnit 5 interactive document
Unit 5 interactive document
Afonso DaCosta
 
Adrblogs
AdrblogsAdrblogs
Information Retrieval - Evaluation
Information Retrieval - EvaluationInformation Retrieval - Evaluation
Information Retrieval - Evaluation
Geunhee Cho
 
Indian Standard IS 11769 part3 2005 for Safe Usage of Asbestos Products
Indian Standard IS 11769 part3 2005 for Safe Usage of Asbestos ProductsIndian Standard IS 11769 part3 2005 for Safe Usage of Asbestos Products
Indian Standard IS 11769 part3 2005 for Safe Usage of Asbestos Products
PGE India - PILOT Gaskets
 
CCNA 1 - Itn instructor ppt_chapter3
CCNA 1 - Itn instructor ppt_chapter3CCNA 1 - Itn instructor ppt_chapter3
CCNA 1 - Itn instructor ppt_chapter3
Yerald Méndez Hernández
 
Evaluation in IR system (검색 시스템의 평가)
Evaluation in IR system (검색 시스템의 평가)Evaluation in IR system (검색 시스템의 평가)
Evaluation in IR system (검색 시스템의 평가)
Minsub Yim
 
Origen y evolución del léxico castellano
Origen y evolución del léxico castellanoOrigen y evolución del léxico castellano
Origen y evolución del léxico castellano
lenguaieda
 
발표자료만들때 알아야할 기본사항들
발표자료만들때 알아야할 기본사항들발표자료만들때 알아야할 기본사항들
발표자료만들때 알아야할 기본사항들
김 성남
 
Epidemiology and public health aspects of TB in india
Epidemiology and public health aspects of TB in indiaEpidemiology and public health aspects of TB in india
Epidemiology and public health aspects of TB in india
Shyam Ashtekar
 
EquityDaily.pdf
EquityDaily.pdfEquityDaily.pdf
Documentation and publishing
Documentation and publishingDocumentation and publishing
Documentation and publishingChris Mills
 

Viewers also liked (14)

Curriculum Attore Maurizio Panfilo con foto
Curriculum Attore Maurizio Panfilo con fotoCurriculum Attore Maurizio Panfilo con foto
Curriculum Attore Maurizio Panfilo con foto
 
Photo shoot
Photo shootPhoto shoot
Photo shoot
 
Was ist das für 1 Omni-Channel?
Was ist das für 1 Omni-Channel? Was ist das für 1 Omni-Channel?
Was ist das für 1 Omni-Channel?
 
Unit 5 interactive document
Unit 5 interactive documentUnit 5 interactive document
Unit 5 interactive document
 
Adrblogs
AdrblogsAdrblogs
Adrblogs
 
Information Retrieval - Evaluation
Information Retrieval - EvaluationInformation Retrieval - Evaluation
Information Retrieval - Evaluation
 
Indian Standard IS 11769 part3 2005 for Safe Usage of Asbestos Products
Indian Standard IS 11769 part3 2005 for Safe Usage of Asbestos ProductsIndian Standard IS 11769 part3 2005 for Safe Usage of Asbestos Products
Indian Standard IS 11769 part3 2005 for Safe Usage of Asbestos Products
 
CCNA 1 - Itn instructor ppt_chapter3
CCNA 1 - Itn instructor ppt_chapter3CCNA 1 - Itn instructor ppt_chapter3
CCNA 1 - Itn instructor ppt_chapter3
 
Evaluation in IR system (검색 시스템의 평가)
Evaluation in IR system (검색 시스템의 평가)Evaluation in IR system (검색 시스템의 평가)
Evaluation in IR system (검색 시스템의 평가)
 
Origen y evolución del léxico castellano
Origen y evolución del léxico castellanoOrigen y evolución del léxico castellano
Origen y evolución del léxico castellano
 
발표자료만들때 알아야할 기본사항들
발표자료만들때 알아야할 기본사항들발표자료만들때 알아야할 기본사항들
발표자료만들때 알아야할 기본사항들
 
Epidemiology and public health aspects of TB in india
Epidemiology and public health aspects of TB in indiaEpidemiology and public health aspects of TB in india
Epidemiology and public health aspects of TB in india
 
EquityDaily.pdf
EquityDaily.pdfEquityDaily.pdf
EquityDaily.pdf
 
Documentation and publishing
Documentation and publishingDocumentation and publishing
Documentation and publishing
 

Similar to Gbroccolo foss4 guk2016_brin4postgis

GBroccolo JRouhaud pgconfeu2016_brin4postgis
GBroccolo JRouhaud pgconfeu2016_brin4postgisGBroccolo JRouhaud pgconfeu2016_brin4postgis
GBroccolo JRouhaud pgconfeu2016_brin4postgis
Giuseppe Broccolo
 
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
 
Indexes in PostgreSQL (10)
Indexes in PostgreSQL (10)Indexes in PostgreSQL (10)
Indexes in PostgreSQL (10)
Giuseppe Broccolo
 
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...
pgdayrussia
 
Spatial functions in MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and others
Spatial functions in  MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and othersSpatial functions in  MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and others
Spatial functions in MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and othersHenrik Ingo
 
20210301_PGconf_Online_GPU_PostGIS_GiST_Index
20210301_PGconf_Online_GPU_PostGIS_GiST_Index20210301_PGconf_Online_GPU_PostGIS_GiST_Index
20210301_PGconf_Online_GPU_PostGIS_GiST_Index
Kohei KaiGai
 
Graph operations in Git version control system
Graph operations in Git version control systemGraph operations in Git version control system
Graph operations in Git version control system
Jakub Narębski
 
Lrz kurs: big data analysis
Lrz kurs: big data analysisLrz kurs: big data analysis
Lrz kurs: big data analysis
Ferdinand Jamitzky
 
Omnibus database machine
Omnibus database machineOmnibus database machine
Omnibus database machine
Aleck Landgraf
 
PostgreSQL 13 New Features
PostgreSQL 13 New FeaturesPostgreSQL 13 New Features
PostgreSQL 13 New Features
José Lin
 
LSGAN - SIMPle(Simple Idea Meaningful Performance Level up)
LSGAN - SIMPle(Simple Idea Meaningful Performance Level up)LSGAN - SIMPle(Simple Idea Meaningful Performance Level up)
LSGAN - SIMPle(Simple Idea Meaningful Performance Level up)
Hansol Kang
 
Developing Geospatial software with Python, Part 1
Developing Geospatial software with Python, Part 1Developing Geospatial software with Python, Part 1
Developing Geospatial software with Python, Part 1
Paolo Corti
 
Japan Lustre User Group 2014
Japan Lustre User Group 2014Japan Lustre User Group 2014
Japan Lustre User Group 2014
Hitoshi Sato
 
What’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributorWhat’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributor
Masahiko Sawada
 
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRasterFOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
Jorge Arevalo
 
SFScon22 - Anton Dignoes - Managing Temporal Data in PostgreSQL.pdf
SFScon22 - Anton Dignoes - Managing Temporal Data in PostgreSQL.pdfSFScon22 - Anton Dignoes - Managing Temporal Data in PostgreSQL.pdf
SFScon22 - Anton Dignoes - Managing Temporal Data in PostgreSQL.pdf
South Tyrol Free Software Conference
 
Raster Data In GeoServer And GeoTools: Achievements, Issues And Future Develo...
Raster Data In GeoServer And GeoTools: Achievements, Issues And Future Develo...Raster Data In GeoServer And GeoTools: Achievements, Issues And Future Develo...
Raster Data In GeoServer And GeoTools: Achievements, Issues And Future Develo...
GeoSolutions
 
An FPGA-based acceleration methodology and performance model for iterative st...
An FPGA-based acceleration methodology and performance model for iterative st...An FPGA-based acceleration methodology and performance model for iterative st...
An FPGA-based acceleration methodology and performance model for iterative st...
NECST Lab @ Politecnico di Milano
 
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth ThomasHoly smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
AMD Developer Central
 
Developing PGTop for Android
Developing PGTop for AndroidDeveloping PGTop for Android
Developing PGTop for Android
Mark Wong
 

Similar to Gbroccolo foss4 guk2016_brin4postgis (20)

GBroccolo JRouhaud pgconfeu2016_brin4postgis
GBroccolo JRouhaud pgconfeu2016_brin4postgisGBroccolo JRouhaud pgconfeu2016_brin4postgis
GBroccolo JRouhaud pgconfeu2016_brin4postgis
 
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...
 
Indexes in PostgreSQL (10)
Indexes in PostgreSQL (10)Indexes in PostgreSQL (10)
Indexes in PostgreSQL (10)
 
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...
PG Day'14 Russia, GIN — Stronger than ever in 9.4 and further, Александр Коро...
 
Spatial functions in MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and others
Spatial functions in  MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and othersSpatial functions in  MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and others
Spatial functions in MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and others
 
20210301_PGconf_Online_GPU_PostGIS_GiST_Index
20210301_PGconf_Online_GPU_PostGIS_GiST_Index20210301_PGconf_Online_GPU_PostGIS_GiST_Index
20210301_PGconf_Online_GPU_PostGIS_GiST_Index
 
Graph operations in Git version control system
Graph operations in Git version control systemGraph operations in Git version control system
Graph operations in Git version control system
 
Lrz kurs: big data analysis
Lrz kurs: big data analysisLrz kurs: big data analysis
Lrz kurs: big data analysis
 
Omnibus database machine
Omnibus database machineOmnibus database machine
Omnibus database machine
 
PostgreSQL 13 New Features
PostgreSQL 13 New FeaturesPostgreSQL 13 New Features
PostgreSQL 13 New Features
 
LSGAN - SIMPle(Simple Idea Meaningful Performance Level up)
LSGAN - SIMPle(Simple Idea Meaningful Performance Level up)LSGAN - SIMPle(Simple Idea Meaningful Performance Level up)
LSGAN - SIMPle(Simple Idea Meaningful Performance Level up)
 
Developing Geospatial software with Python, Part 1
Developing Geospatial software with Python, Part 1Developing Geospatial software with Python, Part 1
Developing Geospatial software with Python, Part 1
 
Japan Lustre User Group 2014
Japan Lustre User Group 2014Japan Lustre User Group 2014
Japan Lustre User Group 2014
 
What’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributorWhat’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributor
 
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRasterFOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
 
SFScon22 - Anton Dignoes - Managing Temporal Data in PostgreSQL.pdf
SFScon22 - Anton Dignoes - Managing Temporal Data in PostgreSQL.pdfSFScon22 - Anton Dignoes - Managing Temporal Data in PostgreSQL.pdf
SFScon22 - Anton Dignoes - Managing Temporal Data in PostgreSQL.pdf
 
Raster Data In GeoServer And GeoTools: Achievements, Issues And Future Develo...
Raster Data In GeoServer And GeoTools: Achievements, Issues And Future Develo...Raster Data In GeoServer And GeoTools: Achievements, Issues And Future Develo...
Raster Data In GeoServer And GeoTools: Achievements, Issues And Future Develo...
 
An FPGA-based acceleration methodology and performance model for iterative st...
An FPGA-based acceleration methodology and performance model for iterative st...An FPGA-based acceleration methodology and performance model for iterative st...
An FPGA-based acceleration methodology and performance model for iterative st...
 
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth ThomasHoly smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
 
Developing PGTop for Android
Developing PGTop for AndroidDeveloping PGTop for Android
Developing PGTop for Android
 

Recently uploaded

Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
g4dpvqap0
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
ahzuo
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
NABLAS株式会社
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
oz8q3jxlp
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptxData_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
AnirbanRoy608946
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
AbhimanyuSinha9
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
u86oixdj
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
Subhajit Sahu
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
ahzuo
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
dwreak4tg
 
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
slg6lamcq
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 

Recently uploaded (20)

Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptxData_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
Data_and_Analytics_Essentials_Architect_an_Analytics_Platform.pptx
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
 
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
一比一原版(UniSA毕业证书)南澳大学毕业证如何办理
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 

Gbroccolo foss4 guk2016_brin4postgis

  • 1. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it June, 14th 2016 BRIN indexes on geospatial databases www.2ndquadrant.com
  • 2. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it ~$ 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 Indexes & PostgreSQLIndexes & PostgreSQL • Binary structures on disc: – Indexing organised in nodes into 8kB pages – Nodes point to table rows • 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 Geospatial indexes in PostgreSQLGeospatial indexes in PostgreSQL • All datatypes can be indexed in principle... – ...just define the needed Operator Class! • Operators & support functions – ...define how the data has to be stored into the index nodes • Geospatial data: – can be larger than 8kB – Is generally a varlena – a single node cannot be contained into a single page
  • 5. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PostGIS datatypes & GiST indexingPostGIS datatypes & GiST indexing 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
  • 6. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it 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?
  • 7. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it A new index: Block Range Indexing (PG 9.5)A new index: Block Range Indexing (PG 9.5) CREATE INDEX idx ON table USING brin(column) WITH (pages_per_range=10); data must be physically sorted on disk! index node → row index node → block less specific than GiST! Really small! 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB (S. Riggs, A. Herrera)
  • 8. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it BRIN support for PostGISBRIN support for PostGIS https://github.com/dalibo/postgis/tree/for_upstream Julien RouhaudRonan Dunklau me
  • 9. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it BRIN support for PostGISBRIN support for PostGIS NO kNN SUPPORT!! – Different OpClass 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) – Operators: &&, @, ~ (2D) - &&& (3D, 4D) 8kB8kB8kB8kB 8kB8kB8kB8kB
  • 10. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it 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
  • 11. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it 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
  • 12. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it 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
  • 13. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it 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)
  • 14. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it ...what about...what about INSERTINSERT’s?’s? INSERT INTO points SELECT ST_MakePoint(a, a, a) FROM generate_series(1, 1000) AS f(a); GiST 6 times than insertions without index BRIN (10) 3 times than insertions without index BRIN (128) 2 times than insertions without index ...blocks could be “not sorted” anymore!
  • 15. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it Manage LiDAR data with PostgreSQL is it possible? Is the relational approach valid for point clouds?Is the relational approach valid for point clouds?
  • 16. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it PostgreSQL & LiDARPostgreSQL & LiDAR • PostgreSQL is a relational DBMS with an extension for LiDAR data: pg_pointcloud • Part of the OpenGeo suite, completely compatible with PostGIS – two new datatype: pcpoint, pcpatch (compressed set of points) • N points (with all attributes from the survey) → 1 patch → 1 record – compatible with PDAL drivers to import data directly from .las 32b 32b 32b 16b https://github.com/pgpointcloud/pointcloud
  • 17. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it Relational approach to LiDAR data with PGRelational approach to LiDAR data with PG • GiST indexing in PostGIS • 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 ) → few % can be properly indexed! http://www.slideshare.net/GiuseppeBroccolo/gbroccolo-foss4-geugeodbindex
  • 18. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it The LiDAR dataset: the ahn2 projectThe LiDAR dataset: the ahn2 project • 3D point cloud, coverage: almost the whole Netherlands – EPSG: 28992, ~8 points/m2 • 1.6TB, ~250G points in ~560M patches (compression: ~10x) – PDAL driver – filter.chipper • available RAM: 16GB • the point structure: X Y Z scan LAS time RGB chipper 32b 32b 32b 40b 16b 64b 48b 32b the “indexed” part (can be converted to PostGIS datatype) (thanks to Tom Van Tilburg)
  • 19. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it Typical searches on ahn2 -Typical searches on ahn2 - x3d_viewerx3d_viewer • Intersection with a polygon (PostGIS) – the part that lasts longer – need indexes here! • Patch “explosion” + NN sorting (pg_PointCloud+PostGIS) • constrained Delaunay Triangulation (SFCGAL)
  • 20. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it WITH patches AS ( SELECT patches FROM ahn2 WHERE patches && ST_GeomFromText(‘POLYGON(...)’) ), points AS ( SELECT ST_Explode(patches) AS points FROM patches ), sorted_points AS ( SELECT points, ST_DumpPoints(ST_GeomFromText(‘POLYGON(...)’))).geom AS poly_pt FROM points ORDER BY points <#> poly_pt LIMIT 1; ), sel AS ( SELECT points FROM sorted_points WHERE points && ST_GeomFromText(‘POLYGON(...)’) ) SELECT ST_Dump(ST_Triangulate2DZ(ST_Collect(points))) FROM sel; All in the DB & just with one query!All in the DB & just with one query!
  • 21. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it patches && polygons - GiST performancepatches && polygons - GiST performance GiST 2.5 days GiST 29GB index building index size polygon size timing ~O(10m) ~20ms ~O(100m) ~60ms ~O(1Km) ~3s ~O(10km) hours searches based on GiST index not contained in RAM anymore (~5G points → ~3%)
  • 22. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it patches && polygons - BRIN performancepatches && polygons - BRIN performance BRIN 4 h BRIN 15MB index building polygon size timing ~O(m) ~150s searches based on BRIN index size
  • 23. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it patches && polygons - BRIN performancepatches && polygons - BRIN performance BRIN 5 h BRIN 14MB index building polygon size timing ~O(m) ~150s searches based on BRIN How data was inserted... LASLASLASLASLASLAS chipper chipper chipper PDAL driver (parallel processes) ahn2 index size
  • 24. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it Spatial sorting of a LiDAR datasetSpatial sorting of a LiDAR dataset CREATE INDEX patch_geohash ON ahn2 USING btree (ST_GeoHash(ST_Transform(Geometry(patch), 4326), 20)); CLUSTER ahn2 USING patch_geohash; Morton order [http://geohash.org/] Need more than 2X table size free space Relatively fast!
  • 25. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it Spatial sorting of a LiDAR datasetSpatial sorting of a LiDAR dataset CREATE TABLE ahn2_sorted ON ahn2 AS SELECT * FROM ahn2 ORDER BY ST_GeoHash(ST_Transform(Geometry(patch), 4326), 10) COLLATE “C”; Morton order [http://geohash.org/] Just need size for a second table Slower than clustering using the index!
  • 26. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it Spatial sorting of a LiDAR datasetSpatial sorting of a LiDAR dataset CREATE TABLE ahn2_sorted ON ahn2 AS SELECT * FROM ahn2 ORDER BY ST_GeoHash(ST_Transform(Geometry(patch), 4326), 10) COLLATE “C”; Morton order [http://geohash.org/] Just need size for a second table Slower than clustering using the index! 45 hours
  • 27. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it patches && polygons – BRIN performancepatches && polygons – BRIN performance polygon size BRIN timing GiST timing ~O(10m) ~380ms ~20ms ~O(100m) ~400ms ~60ms ~O(1Km) ~2.7s ~3s ~O(10km) ~4.7s hours • After sorting: 150s→380ms • GiST X20 faster than BRIN [r~O(10m)] – BRIN X200 faster than SeqScan • BRIN X1000 faster than SeqScan [r~O(100m)] • • BRIN ~ GiST [r~O(1Km)] • Just BRIN is used for searches r>1km
  • 28. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it is the drop in performance acceptable?is the drop in performance acceptable? BRIN searches = x20 GiST searches = x10÷x100 GiST searches = x10÷x100 GiST searches patch explosion + NN sorting constrained triangulation
  • 29. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it the future of the project...add kNN supportthe future of the project...add kNN support 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB 8kB8kB8kB8kB k get blocks gradually included within the k parameter, as already made in GiST with single tuples WIP…sponsorships are welcome! ORDER BY geoms <-> point LIMIT N
  • 30. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it 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 • Can be relational approach to LiDAR data valid with PostgreSQL? – Yes, at least for bbox inclusion searches – make sure that data has the same sequentiality of .las
  • 31. 2ndQuadrant Italia Giuseppe Broccolo – giuseppe.broccolo@2ndquadrant.it 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