Converting 85% of Dutch Primary Schools from Oracle to PostgreSQL - - PowerPoint PPT Presentation

converting 85 of dutch primary schools from oracle to
SMART_READER_LITE
LIVE PREVIEW

Converting 85% of Dutch Primary Schools from Oracle to PostgreSQL - - PowerPoint PPT Presentation

Converting 85% of Dutch Primary Schools from Oracle to PostgreSQL Martijn Dashorst topicus.nl Mart n Dashorst @dashorst martijndashorst.com github.com/dashorst I'd rather not work with databases Martijn Dashorst (1997, first job


slide-1
SLIDE 1

Converting 85% of Dutch Primary Schools 
 from Oracle to PostgreSQL

Martijn Dashorst topicus.nl

slide-2
SLIDE 2

Martijn Dashorst

@dashorst martijndashorst.com github.com/dashorst

slide-3
SLIDE 3

“I'd rather not work with databases”

Martijn Dashorst (1997, first job interview)

slide-4
SLIDE 4

Big thank you to Klaasjan Brand

slide-5
SLIDE 5

Please Give Feedback at
 https://2019.pgconf.eu/f

slide-6
SLIDE 6

What is ParnasSys? Why migrate? Planning Stages Conclusions & Questions

slide-7
SLIDE 7

Dutch Education System

AGES

4-12 13-16/18 16-23 Primary Education Secondary Education Vocational/University Education

pre-vocational (4 yrs), pre-applied science (5 yrs), pre-research university (6 yrs) vocational (4 yrs), applied science (4 yrs, bachelor), pre-research university (bachelor/master) EDUCATION TYPE

slide-8
SLIDE 8

Primary Education (4-12)

1.5M

students

141k

employees 6973 schools

ages 4-12, 2019-2020 2018 2018 Source: https://www.onderwijsincijfers.nl

slide-9
SLIDE 9

Financing Primary Schools

government school teachers buildings materials

taxes lumpsum

number of
 students
 at 1 October

slide-10
SLIDE 10

Financing Primary Schools

government school teachers buildings materials

taxes lumpsum

number of
 students
 at 1 October administration

slide-11
SLIDE 11

ParnasSys ~ noun. 


  • 1. A SaaS to run primary schools by keeping student

records for school financing, student counseling and guidance, attendance keeping and communicating with parents 


slide-12
SLIDE 12

ParnasSys ~ noun. 


  • 1. A SaaS to run primary schools by keeping student

records for school financing, student counseling and guidance, attendance keeping and communicating with parents

  • 2. The only pinkmagenta administration 


system in the world

slide-13
SLIDE 13
slide-14
SLIDE 14
slide-15
SLIDE 15

Java Web App Hibernate (ORM) Business Objects (SAP) MAXDB/SAPDB

Single database Single schema Multi-tenant

Development started October 2003 Production in 
 April 2004

slide-16
SLIDE 16

First Database Migration in 2005

SAPDB/MAXDB ORACLE

User base growing fast Unpredictable query performance in MaxDB "Nobody got ever fired for buying Oracle"

slide-17
SLIDE 17

85% of dutch primary schools use ParnasSys ~5M student dossiers in our database 1,270,000 students in 2019-2020

2019

slide-18
SLIDE 18

800+ pages 360 tables data & indices ~ 2TB user files ~ 5TB

slide-19
SLIDE 19

What is ParnasSys? Why migrate? Planning Stages Conclusions & Questions

slide-20
SLIDE 20

Mismatch Between Future of Oracle and our Product

slide-21
SLIDE 21

Cost Structure of Running Oracle Not Compatible with our Profitability

slide-22
SLIDE 22

The Oracle Migration Assistant Paid Us a Visit

TM

slide-23
SLIDE 23

The stranglehold


  • f the software giants

[...] Especially Oracle would force unfair contracts upon clients, and claim many millions per year of late payments. [...]

http://fd.nl/weekend/1318745/de-wurggreep-van-de-softwarereuzen

slide-24
SLIDE 24

Developer Happiness Or How Do I Run My Database

  • n My Local Machine
slide-25
SLIDE 25

DevOps Happiness on Oracle is Incompatible with our Profitability

slide-26
SLIDE 26

What is ParnasSys? Why migrate? Planning Stages Conclusions & Questions

slide-27
SLIDE 27

Inventory

  • Database contents
  • Java Application Code
  • Business Objects Universe
  • Business Objects Reports
  • Backup & Restore
  • Monitoring
  • Training
  • No stored procedures
  • No custom functions
  • No triggers
slide-28
SLIDE 28

Seasonality of Education

slide-29
SLIDE 29

2 Moments in a Year to Migrate: X-Mas & Summer Vacation

slide-30
SLIDE 30

X-Mass 2 weeks

23 December 2019–5 January 2020

slide-31
SLIDE 31

Summer vacation(s)

North 15 juli 2019–23 august 2019 Middle 22 juli 2019-–30 august 2019 South 8 juli 2019–16 august 2019

slide-32
SLIDE 32

Ideal migration moment:
 start of summer vacation

slide-33
SLIDE 33

Stage 1: make it run


incorrectly, correctly, fast

Stage 2: migrate production


in accordance to customer expectations

slide-34
SLIDE 34

1 Year Migration

slide-35
SLIDE 35

1 Year Migration 3 Year Migration

slide-36
SLIDE 36

What is ParnasSys? Why migrate? Planning Stages Conclusions & Questions

slide-37
SLIDE 37

Stage 1: make it run

slide-38
SLIDE 38

Free Works™ Great to find issues in your application

slide-39
SLIDE 39

Perl


“The only language that looks the same before and after RSA encryption”

Direct datatype mapping


E.G. number(1,0) does not map to boolean

Slow


One import takes whole day

Stable or fast (pick one)


Single-threaded: stable but slow
 Multi-threaded: fast but unstable

One-way, big bang only


slide-40
SLIDE 40

Differences between Oracle and PostgreSQL

“The good thing about standards is that there are so many to choose from.”

― Andrew S. Tanenbaum

slide-41
SLIDE 41

Mapping datatypes

Oracle PostgreSQL number(1,0) number(1,0) boolean Java int boolean enum Sex {
 Female, Male
 } Business study year (1-8) present (yes/no) sex (female/male) number(1,0) number(1,0) number(1,0) varchar2(6) varchar2(6)

slide-42
SLIDE 42

ORM is 100% portable

@Basic @Temporal(TemporalType.DATE) private Date birthdate; @Formula("add_months(birthdate, (to_char(sysdate, 'yyyy') - to_char(birthdate, 'yyyy')) * 12)") @Basic @Temporal(TemporalType.DATE) private Date birthday; CREATE OR REPLACE FUNCTION verjaardag(geboortedatum IN DATE) RETURN DATE IS BEGIN RETURN add_months(geboortedatum-1, 
 (to_char(sysdate, 'yyyy') - to_char(geboortedatum, 'yyyy')) * 12)+1; END;

slide-43
SLIDE 43

Oracle speaks in tongues

select 1 from dual select nvl(null, 'n/a') from dual select * from (select x,y from ...) where rownum between 100 and 110 sysdate trunc

slide-44
SLIDE 44

Performance

ID ORGANIZATION NAME BIRTHDATE ...
 14342 1231 JOHN SMITH 2010-09-23 14345 1231 MARTIJN DASHORST 2011-03-12 ... ID ORGANIZATION NAME
 151231 1231 Group 1A 151232 1231 Group 1B ...

tenant identifier

slide-45
SLIDE 45

Oracle is smarter...

UPDATE testresult tr SET tr.endresult = TRUE WHERE tr.organisation = ? AND tr.testpart IN ( SELECT part1.id FROM testpart part1 WHERE part1.preference = ( SELECT MIN(part2.preference) FROM testresult tr3 INNER JOIN testpart part2 ON tr3.testpart = part2.id WHERE part2.preference > 0 AND tr3.score IS NOT NULL AND tr3.test = tr.test AND ((part1.usemodulenorm IS NULL AND part2.usemodulenorm IS NULL) OR part1.usemodulenorm = part2.usemodulenorm)))

slide-46
SLIDE 46

Oracle is smarter...

UPDATE testresult tr SET tr.endresult = TRUE WHERE tr.organisation = ? AND tr.testpart IN ( SELECT part1.id FROM testpart part1 WHERE part1.preference = ( SELECT MIN(part2.preference) FROM testresult tr3 INNER JOIN testpart part2 ON tr3.testpart = part2.id WHERE part2.preference > 0 AND tr3.score IS NOT NULL AND tr3.test = tr.test AND ((part1.usemodulenorm IS NULL AND part2.usemodulenorm IS NULL) OR part1.usemodulenorm = part2.usemodulenorm))) UPDATE testresult tr SET tr.endresult = TRUE WHERE tr.organisation = ? AND tr.testpart IN ( SELECT part1.id FROM testpart part1 WHERE part1.preference = ( SELECT MIN(part2.preference) FROM testresult tr3 INNER JOIN testpart part2 ON tr3.testpart = part2.id WHERE part2.preference > 0 AND tr3.score IS NOT NULL AND tr3.test = tr.test AND ((part1.usemodulenorm IS NULL AND part2.usemodulenorm IS NULL) OR part1.usemodulenorm = part2.usemodulenorm) AND tr3.organisation = tr.organisation))

100x
 improvement

slide-47
SLIDE 47

Java Web App Business Objects (SAP) PDF Universe Report definition Parameters PDF

slide-48
SLIDE 48
slide-49
SLIDE 49

Teachers Generate a lot of PDFs


but that's OK, because 


Business Objects generates a lot of SQL

slide-50
SLIDE 50

Business Objects 
 can be a bit nostalgic

slide-51
SLIDE 51

Quizz!

SELECT * FROM A, B WHERE B.column(+) = A.column

SELECT * FROM A RIGHT OUTER JOIN B ON B.column = A.column SELECT * FROM B LEFT OUTER JOIN A ON B.column = A.column SELECT * FROM A LEFT OUTER JOIN B ON B.column = A.column SELECT * FROM B RIGHT OUTER JOIN A ON B.column = A.column

1 2 3 4

slide-52
SLIDE 52

Quizz!

SELECT * FROM A, B WHERE B.column(+) = A.column

SELECT * FROM A RIGHT OUTER JOIN B ON B.column = A.column SELECT * FROM B LEFT OUTER JOIN A ON B.column = A.column

1 2

slide-53
SLIDE 53

Production ready?

slide-54
SLIDE 54

Application works Business Objects works

GO!

slide-55
SLIDE 55

Application works Business Objects works

GO!

slide-56
SLIDE 56

How long takes migration? Behavior of application under actual load?


  • Heavy use of application side caching in Java process

  • Modification of data

  • Synthetic tests lie

Can we fall back to Oracle?

slide-57
SLIDE 57

Stage 2: Migrate Production

slide-58
SLIDE 58

Need help...
 1-800-KILLORACLE

slide-59
SLIDE 59

Why don't you use HVR?

–Splendid Data

slide-60
SLIDE 60

Cross-database replication using redo logs

slide-61
SLIDE 61

Remote UNIX
 Machine Remote XYZ
 Machine Hub Machine PC HVR HVR Scheduler HVR HVR HVR GUI Database Location Hub DB Database Location Integrate Capture Inetd Router Transaction Files Inetd HVR Listener Service

slide-62
SLIDE 62

Lots of databases supported

slide-63
SLIDE 63

Lots of databases supported

slide-64
SLIDE 64

Why HVR?

  • Speed
  • Real-time sync with low latency
  • Options to test prior to actual migration
  • Safe
  • Fallback
  • Expensive tool, but Special Price for Special Friend
slide-65
SLIDE 65

Noteworthy issues

  • Use primary key on each table
  • Fix datatype incompatibilities because of differences between databases


E.G. time in date field ✅ Oracle 🚬 PostgreSQL

  • Disable constraint checking in target database
  • Don't perform DDL changes
  • Don't update too many rows in a table too often
slide-66
SLIDE 66

Oracle based deployment

DB1 PROD

failsafe

DB0 PROD TEST

APP PROD Business Objects APP TEST

ORACLE ORACLE ORACLE

APP PROD APP PROD

Fail safe server Offline Archive Log shipping

slide-67
SLIDE 67

DB0 DB1 DB2 PROD PROD TEST TEST

failsafe

TEST PROD

failsafe

PROD


standby

APP PROD Business Objects APP TEST

ORACLE ORACLE ORACLE ORACLE PSQL PSQL PSQL

HVR migration deployment

slide-68
SLIDE 68

DB0 DB1 DB2 PROD PROD TEST TEST

failsafe

TEST PROD

failsafe

PROD


standby

APP PROD Business Objects APP TEST

ORACLE ORACLE ORACLE ORACLE PSQL PSQL PSQL

Prod Testing Business Objects

slide-69
SLIDE 69

PostgreSQL based deployment

DB1 DB2 PROD

failsafe

DB1 PROD TEST

APP PROD Business Objects APP TEST

PSQL PSQL PSQL

APP PROD APP PROD

DB0 PROD

ORACLE
slide-70
SLIDE 70

D-Day

de-oracle day

22 Juli 2019

slide-71
SLIDE 71
slide-72
SLIDE 72

What is ParnasSys? Why migrate? Planning Stages Conclusions & Questions

slide-73
SLIDE 73

Make a *really* good inventory of things that have to be migrated Pick a strategy that works for you Plan around your business to minimise risk and maximise opportunity A great way to find bugs in your system Don't be afraid to pay for tools and help

slide-74
SLIDE 74

“Nobody got fired from migrating away from Oracle” “Yet”

slide-75
SLIDE 75

Migrate our Secondary Education Application from Oracle to PostgreSQL

slide-76
SLIDE 76

Feedback
 https://2019.pgconf.eu/f

slide-77
SLIDE 77

Questions?

slide-78
SLIDE 78

THANK YOU!

@dashorst martijndashorst.com github.com/dashorst