SlideShare a Scribd company logo
1 of 19
Download to read offline
Managing National Load
OS MasterMap
and Maintaining History
Aileen Heal, Astun Technology
OS MasterMap Topography Layer,
PostGIS,
Loader,
PostgreSQL HSTORE,
&
PostgreSQL Audit trigger 91plus
PostgreSQL
PostgreSQL is a powerful, open source object-relational
database system.
PostgreSQL evolved from the Ingres project. The project was lead
by Michael Stonebaker in1986.
In 1995, two Ph.D. students from Stonebraker's lab, Andrew Yu and
Jolly Chen, replaced Postgres' POSTQUEL query language with an
extended subset of SQL. They renamed the system to Postgres95.
In 1996, Postgres95 departed from academia and started a new life
in the open source world, when the database system took its current
name: PostgreSQL. "Postgres" is still used as an easy-to-pronounce
nick-name.
www.postgresql.org
PostGIS is a spatial database extender for PostgreSQL.
It adds support for geographic objects allowing
location queries to be run in SQL.
PostGIS first release was in 2001.
http://postgis.net/
OS MasterMap Topography Layer
OS MasterMap Topography Layer is the most detailed and accurate view
of Great Britain's landscape – from roads to fields, to buildings and trees,
fences, paths and more.
There are approx 460 million features in OS MasterMap Topography.
Change Only Update (CoU)
Due to the large number of
features in OS MasterMap.
Updates are available as CoU.
Typically a CoU for national
supply is < 6 million features.
https://www.ordnancesurvey.co.uk/busin
ess-and-government/products/topography
-layer.html
Loader
A powerful GML & KML loader (and translator) written in Python that makes
use of OGR 1.9.
Source data can be in GML (including .gz) or KML format and can be output
to any of the formats supported by OGR.
The source data can be prepared and enhanced during loading to
● make it suitable for loading with OGR (useful with complex feature types)
● to add value by deriving attributes
Fairly fast (national cover OS MasterMap in 2 days)
● Run 6 instances in parallel
● Use OGR PGDump driver to output the SQL and use COPY utility to load
data.
http://github.com/AstunTechnology/Loader
Loading CoU
Loading CoU data is basically the same as loading standard
MasterMap.
Two differences
1. Extra feature type
Departed Features.
2. Need to apply the changes
after you have loaded the data.
It is easier if you load the CoU data
into a separate schema e.g.
●
osmm_topo
●
osmm_topo_cou
Loading CoU cont... Applying the Changes
Remove all the departed features from the main holding.
Then, for all the changed records do an UPSERT.
For speed we do a delete and insert.
We do a little bit more….
BUT what about keeping the history? For that we use AUDIT :)
Identify changed areas
● Add the geometry to the departed feature table
● Create a view of changed features
● Create a table of 500m grid squares which have changed
● Use this table to update the tile caches where the data has
changed
Two phased validation
● Compare number of features loaded in CoU tables for each file
with report generated by a python scripts which parses the .gz files
● Load FVDs and compare TOIDs, version number & version data
with updated data.
PostgreSQL HSTORE
A PostgreSQL extension which implements the hstore data type for
storing sets of key/value pairs within a single PostgreSQL value.
This can be useful in various scenarios, such as rows with many
attributes that are rarely examined, or semi-structured data.
Keys and values are simply text strings.
Key function/ operators are:
http://www.postgresql.org/docs/current/static/hstore.html
hstore(record) construct an hstore from a record or row
populate_record(record,
hstore)
replace fields in record with matching values from hstore
hstore – hstore delete matching pairs from left operand (so can store changes)
PostgreSQL Audit trigger 91plus
https://wiki.postgresql.org/wiki/Audit_trigger_91plus
● Generic trigger function used for recording changes to tables
into an audit log table.
● Row values are recorded as HSTORE fields rather than as flat text.
● Auditing can be done coarsely at a statement level or finely at a
row level.
● Control is per-audited-table.
Trigger does not track:
● SELECT
● DDL like ALTER TABLE
● Changes to system catalogs
● Trigger does record that a truncate has happened
but not the values of of the rows affected by the truncate
What's great about
PostgreSQL Audit trigger 91plus?
Obviously the Audit triggers need to be applied before
changes are made to the data.
Let's look at some audit data....
● Very simple to turn audit on
SELECT audit.audit_table('<schema name>.<table name');
● You can audit any table in the database.
● No extra columns required on the tables being audited.
● All changes is held in the table audit.logged_actions.
● Changes are only visible to roles which have the appropriate
privileges
How to Create a “Point in Time” Snapshot
1st
check the table has not be truncated after the ‘snapshot date’!

Using HSTORE function populate_record create view ‘changes_after'
●
the 1st
change per primary key from the audit table after the ‘date’
●
an extra column indicating the change i.e. D, U, I
Changes after view...
CREATE TEMPORARY VIEW changes_after as
SELECT DISTINCT ON (fid) *
FROM (SELECT action, (populate_record(null::osmm_topo.topographicarea,row_data)).*
FROM audit.logged_actions
WHERE logged_actions.schema_name = 'osmm_topo'
AND logged_actions.table_name = 'topographicarea'
AND logged_actions.action_tstamp_tx > '2016-06-01 20:00:00'::timestamp
ORDER BY fid, event_id
) foo;
Create Snapshot
Create a view/table which includes
●
All the records in the current table whose PK is not in
changes_after view
plus
●
All the records in changes_after view where change is D or U
Let's look at some example data....
CREATE TABLE snapshot AS
SELECT *, null as action FROM osmm_topo.topographicarea
WHERE fid NOT IN ( SELECT fid FROM changes_after )
UNION
SELECT * FROM changes_after WHERE action in ('D','U');
Before CoU was applied.
© Crown copyright and database rights 2016 Ordnance Survey 100019153
After CoU was applied.
© Crown copyright and database rights 2016 Ordnance Survey 100019153
Side by side
© Crown copyright and database rights 2016 Ordnance Survey 100019153
So there you have it...
Questions?

More Related Content

Viewers also liked

NATIONAL CERTIFICATE PROFESSIONAL DRIVING
NATIONAL CERTIFICATE PROFESSIONAL DRIVINGNATIONAL CERTIFICATE PROFESSIONAL DRIVING
NATIONAL CERTIFICATE PROFESSIONAL DRIVINGTshepo Njomo Mashiloane
 
[Awad s. hanna]_concrete_formwork_systems_(civil_a(book_zz.org)
[Awad s. hanna]_concrete_formwork_systems_(civil_a(book_zz.org)[Awad s. hanna]_concrete_formwork_systems_(civil_a(book_zz.org)
[Awad s. hanna]_concrete_formwork_systems_(civil_a(book_zz.org)Ammar abbas
 
Porth_Dissertation_ProQuest
Porth_Dissertation_ProQuestPorth_Dissertation_ProQuest
Porth_Dissertation_ProQuestLeslie Porth
 
Learning the Basics of Woodturning
Learning the Basics of Woodturning Learning the Basics of Woodturning
Learning the Basics of Woodturning xtreme43v6
 
Softwares used in project management
Softwares used in project managementSoftwares used in project management
Softwares used in project managementAmmar abbas
 
Design Principals of Technical Theater
Design Principals of Technical TheaterDesign Principals of Technical Theater
Design Principals of Technical Theaterxtreme43v6
 
Work Sample - DirecTV Equity Research Report
Work Sample - DirecTV Equity Research ReportWork Sample - DirecTV Equity Research Report
Work Sample - DirecTV Equity Research ReportVarun James
 
The Marketing Plan, The Organizational Plan & The Financial Plan from Entrepr...
The Marketing Plan, The Organizational Plan & The Financial Plan from Entrepr...The Marketing Plan, The Organizational Plan & The Financial Plan from Entrepr...
The Marketing Plan, The Organizational Plan & The Financial Plan from Entrepr...Muhammad Putra
 
[Vance h. dodson_ph.d.__(auth.)]_concrete_admixtur(book_zz.org)
[Vance h. dodson_ph.d.__(auth.)]_concrete_admixtur(book_zz.org)[Vance h. dodson_ph.d.__(auth.)]_concrete_admixtur(book_zz.org)
[Vance h. dodson_ph.d.__(auth.)]_concrete_admixtur(book_zz.org)Ammar abbas
 

Viewers also liked (14)

NATIONAL CERTIFICATE PROFESSIONAL DRIVING
NATIONAL CERTIFICATE PROFESSIONAL DRIVINGNATIONAL CERTIFICATE PROFESSIONAL DRIVING
NATIONAL CERTIFICATE PROFESSIONAL DRIVING
 
Power
PowerPower
Power
 
Good time
Good timeGood time
Good time
 
KNB[2][8_2_Presales]
KNB[2][8_2_Presales]KNB[2][8_2_Presales]
KNB[2][8_2_Presales]
 
[Awad s. hanna]_concrete_formwork_systems_(civil_a(book_zz.org)
[Awad s. hanna]_concrete_formwork_systems_(civil_a(book_zz.org)[Awad s. hanna]_concrete_formwork_systems_(civil_a(book_zz.org)
[Awad s. hanna]_concrete_formwork_systems_(civil_a(book_zz.org)
 
Good time
Good timeGood time
Good time
 
Porth_Dissertation_ProQuest
Porth_Dissertation_ProQuestPorth_Dissertation_ProQuest
Porth_Dissertation_ProQuest
 
Learning the Basics of Woodturning
Learning the Basics of Woodturning Learning the Basics of Woodturning
Learning the Basics of Woodturning
 
Softwares used in project management
Softwares used in project managementSoftwares used in project management
Softwares used in project management
 
Design Principals of Technical Theater
Design Principals of Technical TheaterDesign Principals of Technical Theater
Design Principals of Technical Theater
 
Work Sample - DirecTV Equity Research Report
Work Sample - DirecTV Equity Research ReportWork Sample - DirecTV Equity Research Report
Work Sample - DirecTV Equity Research Report
 
High/Low Level Design
High/Low Level DesignHigh/Low Level Design
High/Low Level Design
 
The Marketing Plan, The Organizational Plan & The Financial Plan from Entrepr...
The Marketing Plan, The Organizational Plan & The Financial Plan from Entrepr...The Marketing Plan, The Organizational Plan & The Financial Plan from Entrepr...
The Marketing Plan, The Organizational Plan & The Financial Plan from Entrepr...
 
[Vance h. dodson_ph.d.__(auth.)]_concrete_admixtur(book_zz.org)
[Vance h. dodson_ph.d.__(auth.)]_concrete_admixtur(book_zz.org)[Vance h. dodson_ph.d.__(auth.)]_concrete_admixtur(book_zz.org)
[Vance h. dodson_ph.d.__(auth.)]_concrete_admixtur(book_zz.org)
 

Similar to Foss4 guk2016 aileenheal

[PGDay.Seoul 2020] PostgreSQL 13 New Features
[PGDay.Seoul 2020] PostgreSQL 13 New Features[PGDay.Seoul 2020] PostgreSQL 13 New Features
[PGDay.Seoul 2020] PostgreSQL 13 New Featureshyeongchae lee
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 
What’s New In PostgreSQL 9.3
What’s New In PostgreSQL 9.3What’s New In PostgreSQL 9.3
What’s New In PostgreSQL 9.3Pavan Deolasee
 
PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12Andrew Dunstan
 
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 GeoRasterJorge Arevalo
 
PostgreSQL Enterprise Class Features and Capabilities
PostgreSQL Enterprise Class Features and CapabilitiesPostgreSQL Enterprise Class Features and Capabilities
PostgreSQL Enterprise Class Features and CapabilitiesPGConf APAC
 
Oracle applications r12.2, ebr, online patching means lot of work for devel...
Oracle applications r12.2, ebr, online patching   means lot of work for devel...Oracle applications r12.2, ebr, online patching   means lot of work for devel...
Oracle applications r12.2, ebr, online patching means lot of work for devel...Ajith Narayanan
 
PHP Detroit -- MySQL 8 A New Beginning (updated presentation)
PHP Detroit -- MySQL 8 A New Beginning (updated presentation)PHP Detroit -- MySQL 8 A New Beginning (updated presentation)
PHP Detroit -- MySQL 8 A New Beginning (updated presentation)Dave Stokes
 
Php 5.6 From the Inside Out
Php 5.6 From the Inside OutPhp 5.6 From the Inside Out
Php 5.6 From the Inside OutFerenc Kovács
 
The Art of Database Experiments – PostgresConf Silicon Valley 2018 / San Jose
The Art of Database Experiments – PostgresConf Silicon Valley 2018 / San JoseThe Art of Database Experiments – PostgresConf Silicon Valley 2018 / San Jose
The Art of Database Experiments – PostgresConf Silicon Valley 2018 / San JoseNikolay Samokhvalov
 
What's New in Postgres 9.4
What's New in Postgres 9.4What's New in Postgres 9.4
What's New in Postgres 9.4EDB
 
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...Citus Data
 
An evening with Postgresql
An evening with PostgresqlAn evening with Postgresql
An evening with PostgresqlJoshua Drake
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq lsInSync Conference
 
Informix Data Streaming Overview
Informix Data Streaming OverviewInformix Data Streaming Overview
Informix Data Streaming OverviewBrian Hughes
 
PostgreSQL 9.4, 9.5 and Beyond @ COSCUP 2015 Taipei
PostgreSQL 9.4, 9.5 and Beyond @ COSCUP 2015 TaipeiPostgreSQL 9.4, 9.5 and Beyond @ COSCUP 2015 Taipei
PostgreSQL 9.4, 9.5 and Beyond @ COSCUP 2015 TaipeiSatoshi Nagayasu
 
10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQLSatoshi Nagayasu
 

Similar to Foss4 guk2016 aileenheal (20)

An Introduction to Postgresql
An Introduction to PostgresqlAn Introduction to Postgresql
An Introduction to Postgresql
 
Post gispguk
Post gispgukPost gispguk
Post gispguk
 
[PGDay.Seoul 2020] PostgreSQL 13 New Features
[PGDay.Seoul 2020] PostgreSQL 13 New Features[PGDay.Seoul 2020] PostgreSQL 13 New Features
[PGDay.Seoul 2020] PostgreSQL 13 New Features
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
What’s New In PostgreSQL 9.3
What’s New In PostgreSQL 9.3What’s New In PostgreSQL 9.3
What’s New In PostgreSQL 9.3
 
PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12PostgreSQL 8.4 TriLUG 2009-11-12
PostgreSQL 8.4 TriLUG 2009-11-12
 
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
 
PostgreSQL Enterprise Class Features and Capabilities
PostgreSQL Enterprise Class Features and CapabilitiesPostgreSQL Enterprise Class Features and Capabilities
PostgreSQL Enterprise Class Features and Capabilities
 
Oracle applications r12.2, ebr, online patching means lot of work for devel...
Oracle applications r12.2, ebr, online patching   means lot of work for devel...Oracle applications r12.2, ebr, online patching   means lot of work for devel...
Oracle applications r12.2, ebr, online patching means lot of work for devel...
 
PHP Detroit -- MySQL 8 A New Beginning (updated presentation)
PHP Detroit -- MySQL 8 A New Beginning (updated presentation)PHP Detroit -- MySQL 8 A New Beginning (updated presentation)
PHP Detroit -- MySQL 8 A New Beginning (updated presentation)
 
Php 5.6 From the Inside Out
Php 5.6 From the Inside OutPhp 5.6 From the Inside Out
Php 5.6 From the Inside Out
 
The Art of Database Experiments – PostgresConf Silicon Valley 2018 / San Jose
The Art of Database Experiments – PostgresConf Silicon Valley 2018 / San JoseThe Art of Database Experiments – PostgresConf Silicon Valley 2018 / San Jose
The Art of Database Experiments – PostgresConf Silicon Valley 2018 / San Jose
 
What's New in Postgres 9.4
What's New in Postgres 9.4What's New in Postgres 9.4
What's New in Postgres 9.4
 
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
 
An evening with Postgresql
An evening with PostgresqlAn evening with Postgresql
An evening with Postgresql
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
 
Informix Data Streaming Overview
Informix Data Streaming OverviewInformix Data Streaming Overview
Informix Data Streaming Overview
 
PostgreSQL 9.4, 9.5 and Beyond @ COSCUP 2015 Taipei
PostgreSQL 9.4, 9.5 and Beyond @ COSCUP 2015 TaipeiPostgreSQL 9.4, 9.5 and Beyond @ COSCUP 2015 Taipei
PostgreSQL 9.4, 9.5 and Beyond @ COSCUP 2015 Taipei
 
PostgreSQL 9.4
PostgreSQL 9.4PostgreSQL 9.4
PostgreSQL 9.4
 
10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL
 

Recently uploaded

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 

Recently uploaded (20)

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 

Foss4 guk2016 aileenheal

  • 1. Managing National Load OS MasterMap and Maintaining History Aileen Heal, Astun Technology
  • 2. OS MasterMap Topography Layer, PostGIS, Loader, PostgreSQL HSTORE, & PostgreSQL Audit trigger 91plus
  • 3. PostgreSQL PostgreSQL is a powerful, open source object-relational database system. PostgreSQL evolved from the Ingres project. The project was lead by Michael Stonebaker in1986. In 1995, two Ph.D. students from Stonebraker's lab, Andrew Yu and Jolly Chen, replaced Postgres' POSTQUEL query language with an extended subset of SQL. They renamed the system to Postgres95. In 1996, Postgres95 departed from academia and started a new life in the open source world, when the database system took its current name: PostgreSQL. "Postgres" is still used as an easy-to-pronounce nick-name. www.postgresql.org
  • 4. PostGIS is a spatial database extender for PostgreSQL. It adds support for geographic objects allowing location queries to be run in SQL. PostGIS first release was in 2001. http://postgis.net/
  • 5. OS MasterMap Topography Layer OS MasterMap Topography Layer is the most detailed and accurate view of Great Britain's landscape – from roads to fields, to buildings and trees, fences, paths and more. There are approx 460 million features in OS MasterMap Topography. Change Only Update (CoU) Due to the large number of features in OS MasterMap. Updates are available as CoU. Typically a CoU for national supply is < 6 million features. https://www.ordnancesurvey.co.uk/busin ess-and-government/products/topography -layer.html
  • 6. Loader A powerful GML & KML loader (and translator) written in Python that makes use of OGR 1.9. Source data can be in GML (including .gz) or KML format and can be output to any of the formats supported by OGR. The source data can be prepared and enhanced during loading to ● make it suitable for loading with OGR (useful with complex feature types) ● to add value by deriving attributes Fairly fast (national cover OS MasterMap in 2 days) ● Run 6 instances in parallel ● Use OGR PGDump driver to output the SQL and use COPY utility to load data. http://github.com/AstunTechnology/Loader
  • 7. Loading CoU Loading CoU data is basically the same as loading standard MasterMap. Two differences 1. Extra feature type Departed Features. 2. Need to apply the changes after you have loaded the data. It is easier if you load the CoU data into a separate schema e.g. ● osmm_topo ● osmm_topo_cou
  • 8. Loading CoU cont... Applying the Changes Remove all the departed features from the main holding. Then, for all the changed records do an UPSERT. For speed we do a delete and insert.
  • 9. We do a little bit more…. BUT what about keeping the history? For that we use AUDIT :) Identify changed areas ● Add the geometry to the departed feature table ● Create a view of changed features ● Create a table of 500m grid squares which have changed ● Use this table to update the tile caches where the data has changed Two phased validation ● Compare number of features loaded in CoU tables for each file with report generated by a python scripts which parses the .gz files ● Load FVDs and compare TOIDs, version number & version data with updated data.
  • 10. PostgreSQL HSTORE A PostgreSQL extension which implements the hstore data type for storing sets of key/value pairs within a single PostgreSQL value. This can be useful in various scenarios, such as rows with many attributes that are rarely examined, or semi-structured data. Keys and values are simply text strings. Key function/ operators are: http://www.postgresql.org/docs/current/static/hstore.html hstore(record) construct an hstore from a record or row populate_record(record, hstore) replace fields in record with matching values from hstore hstore – hstore delete matching pairs from left operand (so can store changes)
  • 11. PostgreSQL Audit trigger 91plus https://wiki.postgresql.org/wiki/Audit_trigger_91plus ● Generic trigger function used for recording changes to tables into an audit log table. ● Row values are recorded as HSTORE fields rather than as flat text. ● Auditing can be done coarsely at a statement level or finely at a row level. ● Control is per-audited-table. Trigger does not track: ● SELECT ● DDL like ALTER TABLE ● Changes to system catalogs ● Trigger does record that a truncate has happened but not the values of of the rows affected by the truncate
  • 12. What's great about PostgreSQL Audit trigger 91plus? Obviously the Audit triggers need to be applied before changes are made to the data. Let's look at some audit data.... ● Very simple to turn audit on SELECT audit.audit_table('<schema name>.<table name'); ● You can audit any table in the database. ● No extra columns required on the tables being audited. ● All changes is held in the table audit.logged_actions. ● Changes are only visible to roles which have the appropriate privileges
  • 13. How to Create a “Point in Time” Snapshot 1st check the table has not be truncated after the ‘snapshot date’!  Using HSTORE function populate_record create view ‘changes_after' ● the 1st change per primary key from the audit table after the ‘date’ ● an extra column indicating the change i.e. D, U, I
  • 14. Changes after view... CREATE TEMPORARY VIEW changes_after as SELECT DISTINCT ON (fid) * FROM (SELECT action, (populate_record(null::osmm_topo.topographicarea,row_data)).* FROM audit.logged_actions WHERE logged_actions.schema_name = 'osmm_topo' AND logged_actions.table_name = 'topographicarea' AND logged_actions.action_tstamp_tx > '2016-06-01 20:00:00'::timestamp ORDER BY fid, event_id ) foo;
  • 15. Create Snapshot Create a view/table which includes ● All the records in the current table whose PK is not in changes_after view plus ● All the records in changes_after view where change is D or U Let's look at some example data.... CREATE TABLE snapshot AS SELECT *, null as action FROM osmm_topo.topographicarea WHERE fid NOT IN ( SELECT fid FROM changes_after ) UNION SELECT * FROM changes_after WHERE action in ('D','U');
  • 16. Before CoU was applied. © Crown copyright and database rights 2016 Ordnance Survey 100019153
  • 17. After CoU was applied. © Crown copyright and database rights 2016 Ordnance Survey 100019153
  • 18. Side by side © Crown copyright and database rights 2016 Ordnance Survey 100019153
  • 19. So there you have it... Questions?