migrating to postgresql
play

Migrating to PostgreSQL Boriss Mejas Consultant - 2ndQuadrant Air - PowerPoint PPT Presentation

Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Migrating to PostgreSQL Boriss Mejas Consultant - 2ndQuadrant Air Guitar Player https://www. 2ndQuadrant.com Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Why


  1. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Migrating to PostgreSQL Boriss Mejías Consultant - 2ndQuadrant Air Guitar Player https://www. 2ndQuadrant.com

  2. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Why Migrate to PostgreSQL? https://www. 2ndQuadrant.com

  3. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 PostgreSQL ● Open Source – Supported – Extendable ● Advanced ● Reliable ● Standard Compliant https://www. 2ndQuadrant.com

  4. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 PostgreSQL ● It’s an All-Rounder – Low Latency – Big Data – High Availability – “Document” Database ● Sometimes better than dedicated solutions – Scale to petabytes (from Elasticsearch) https://www. 2ndQuadrant.com

  5. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 PostgreSQL ● Awesome Community https://www. 2ndQuadrant.com

  6. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Why Migrate to Open Source? https://www. 2ndQuadrant.com

  7. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Why Migrate to Open Source? Reason #1 is “Cost” https://www. 2ndQuadrant.com

  8. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Why Migrate to Open Source? Reason #1 is “Cost” (or it used to be) https://www. 2ndQuadrant.com

  9. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Top Reasons to Stay in Open Source 1. Competitive features, innovation 2. Freedom from vendor lock-in 3. Quality of solutions 4. Ability to customize and fix 5. Cost https://www.slideshare.net/blackducksoftware/ 2016-future-of-open-source-survey-results https://www. 2ndQuadrant.com

  10. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Migration Timeline ● Effort Assessment ● Decision (is it worth?) ● Preparation ● Testing ● Migration ● Cleanup https://www. 2ndQuadrant.com

  11. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Effort Assessment ● Schema ● Data ● Code – What language? (SQL / Other) – Where? (Client / Server) ● Architecture https://www. 2ndQuadrant.com

  12. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Schema ● Usually the easiest part – Available via common tools ● Map data types as appropriate – Look for simplifications ● Consider custom datatypes – Simpler is better than complex – Complex is better than complicated Zen of Python https://www. 2ndQuadrant.com

  13. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Data Type ● PostgreSQL has several data types ● Classical: text, numbers, boolean, time/date ● Modern: Arrays, JSON ● User-defined: – Composite – Enumerative – Your data type in C https://www. 2ndQuadrant.com

  14. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Data Type Gotcha ● Oracle NUMBER to NUMERIC ● MySQL BOOLEAN to BOOLEAN ● Oracle NULL SELECT first_name || second_name || last_name; https://www. 2ndQuadrant.com

  15. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Data Type Gotcha ● Oracle NUMBER to NUMERIC ● MySQL BOOLEAN to BOOLEAN ● Oracle NULL SELECT first_name || COALESCE(second_name, '') || last_name; https://www. 2ndQuadrant.com

  16. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Architecture Assessment ● High Availability ● Disaster Recovery ● Multi-Master ● Selective Replication https://www. 2ndQuadrant.com

  17. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Target Architecture https://www. 2ndQuadrant.com

  18. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Target Architecture https://www. 2ndQuadrant.com

  19. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Solutions Mapping ● Rich PostgreSQL ecosystem – Core – Contrib / Extensions – Third Party (both FLOSS and proprietary) ● Sometimes difficult to find exact match – Might not be needed – You must match the purpose , not the tool https://www. 2ndQuadrant.com

  20. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 https://www. 2ndQuadrant.com

  21. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Application Code ● Many programming languages and frameworks have PostgreSQL drivers – Not an issue (usually) ● Real issue: SQL variants with different feature sets: – Emulate missing features – Remove useless emulations https://www. 2ndQuadrant.com

  22. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Application Code Gotcha ● SELECT 1 FROM DUAL; ● Upper case default in Oracle – CREATE TABLE DUAL (); – DUAL → dual → “DUAL” ● Exceptions in store procedures https://www. 2ndQuadrant.com

  23. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Planning the Migration ● The Assessment includes (at least) one Plan – Time – Cost – Contingency / Rollback https://www. 2ndQuadrant.com

  24. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Take Advantage of the Application ● Some applications support multiple databases ● They have done all the major part of the work ● Functions, procedures, data types. It all works already with PostgreSQL ● Just need to migrate the data https://www. 2ndQuadrant.com

  25. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Don’t Panic https://www. 2ndQuadrant.com

  26. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Vanilla Deployment https://www. 2ndQuadrant.com

  27. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Bilberry Deployment https://www. 2ndQuadrant.com

  28. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Get the Schema Defjnition https://www. 2ndQuadrant.com

  29. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Migrate Data https://www. 2ndQuadrant.com

  30. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Migrate Data Downtime � https://www. 2ndQuadrant.com

  31. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Redirect the Application https://www. 2ndQuadrant.com

  32. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Redirect the Application Showtime! � https://www. 2ndQuadrant.com

  33. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Alternative Strategy: Phasing Out ● Use PostgreSQL for new services – Keep old services as they are ● Useful when standard plans are too complicated / expensive ● No need to migrate old data and code – Easier: “just” plan new system https://www. 2ndQuadrant.com

  34. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Phasing Out and Integration ● Integrate new PostgreSQL with existing DBs ● Preserve continuity of services ● Foreign Data Wrappers – Pluggable adaptors for other systems – SQL/MED standard – Some of them are read/write https://www. 2ndQuadrant.com

  35. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Alternative Strategy: Preparation ● Modify the existing system before migrating ● Make it nearer to PostgreSQL – Stop using incompatible features – Rewrite/simplify queries ● Enables application compatibility ● Makes migration easier / cheaper / faster https://www. 2ndQuadrant.com

  36. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Testing ● Compatibility ● Performance ● The migration process includes writing tests https://www. 2ndQuadrant.com

  37. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Performance Testing ● Test must include difficult / critical queries ● Ensure that newer optimisations don’t cause regressions on other queries ● Use pgbench (custom scripts) ● Analyse the current workload ● Reproduce it ● Properly dimension hardware https://www. 2ndQuadrant.com

  38. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Scripted Migration ● The migration procedure should be scripted as much as possible ● A script can be: – Repeated – Versioned – Benchmarked – Tested https://www. 2ndQuadrant.com

  39. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Scripted Migration ● The migration procedure should be scripted as much as possible ● A script can be: – Repeated – Versioned – Benchmarked – Tested (in staging environment) https://www. 2ndQuadrant.com

  40. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Scripted Migration ● The migration procedure should be scripted as much as possible ● A script can be: – Repeated – Versioned – Benchmarked – Tested (in staging environment, please!) https://www. 2ndQuadrant.com

  41. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Thoughts ● Focus on the purpose not on emulating ● Make a plan ● Test, test, test ● Learn PostgreSQL https://www. 2ndQuadrant.com

  42. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Thoughts ● Focus on the purpose not on emulating ● Make a plan ● Test, test, test, test, test, test, test ● Learn PostgreSQL https://www. 2ndQuadrant.com

  43. Migrating to PostgreSQL / PgConf.EU Milano, 16 October 2019 Thoughts ● Focus on the purpose not on emulating ● Make a plan ● Test, test, test, test, test, test, test ● Learn PostgreSQL and get help https://www. 2ndQuadrant.com

Recommend


More recommend