® npr.org Migration From Oracle to MySQL An NPR Case Study By Joanne Garlow.

Slides:



Advertisements
Similar presentations
Enhancing Productivity with MySQL 5.6 New Features
Advertisements

Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
Inner Architecture of a Social Networking System Petr Kunc, Jaroslav Škrabálek, Tomáš Pitner.
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Ashley Ohmann June 20, * What is Custom SQL? * What can I do with it? * Join conditions * Unions and Self Joins * Ranks * Derived Tables.
Drop in replacement of MySQL. Agenda MySQL branch GPL licence Maria storage engine Virtual columns FederatedX storage engine PBXT storage engine XtraDB.
PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
A comparison of MySQL And Oracle Jeremy Haubrich.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
Information Retrieval in Practice
PHP (2) – Functions, Arrays, Databases, and sessions.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
Introduction to Oracle9i: SQL1 Selected Single-Row Functions.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Overview of Search Engines
Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server.
GOAT SEARCH Revorg GOAT Search Solution (Powered by Lucene)
Phil Brewster  One of the first steps – identify the proper data types  Decide how data (in columns) should be stored and used.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Open Content By Daniel Jacobson and Harold Neal National Public Radio.
ORACLE ONLINE TRAINING Contact our Support Team : SOFTNSOL India: Skype id : softnsoltrainings id:
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
PHP. Basic SQL definition: Database A database which structures data in the form of tables. Each table contains information relevant to a particular.
PHP meets MySQL.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 5 Selected Single-Row Functions. Chapter Objectives  Use the UPPER, LOWER, and INITCAP functions to change the case of field values and character.
Stored Procedures, Triggers, Program Access Dr Lisa Ball 2008.
Oracle Database Administration Lecture 3  Transactions  SQL Language: Additional information  SQL Language: Analytic Functions.
Oracle Database Administration Lecture 2 SQL language.
LIS651 lecture 6 mySQL Thomas Krichel
DBMS Implementation Chapter 6.4 V3.0 Napier University Dr Gordon Russell.
Introduction to CS520/CS596_026 Lecture Two Gordon Tian Fall 2015.
Oracle 11g: SQL Chapter 10 Selected Single-Row Functions.
Views In some cases, it is not desirable for all users to see the entire logical model (that is, all the actual relations stored in the database.) In some.
Most information comes from Chapter 3, MySQL Tutorial: 1 MySQL: Part.
By Shanna Epstein IS 257 September 16, Cnet.com Provides information, tools, and advice to help customers decide what to buy and how to get the.
Chapter 3 Selected Single-Row Functions and Advanced DML & DDL.
Nikolay Kostov Telerik Corporation
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
IFS Intro to Data Management Chapter 5 Getting More Than Simple Columns.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Lecture 8 – SQL Joins – assemble new views from existing tables INNER JOIN’s The Cartesian Product Theta Joins and Equi-joins Self Joins Natural Join.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
1 Session 6: Database Best Practice iNET Academy Open Source Web Development.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Unit-8 Introduction Of MySql. Types of table in PHP MySQL supports various of table types or storage engines to allow you to optimize your database. The.
There’s a particular style to it… Rob Hatton
Introduction to MySQL  Working with MySQL and MySQL Workbench.
uses of DB systems DB environment DB structure Codd’s rules current common RDBMs implementations.
ADVANCED SQL.  The SQL ORDER BY Keyword  The ORDER BY keyword is used to sort the result-set by one or more columns.  The ORDER BY keyword sorts the.
Basics Components of Web Design & Development Basics, Components, Design and Development.
LEC-8 SQL. Indexes The CREATE INDEX statement is used to create indexes in tables. Indexes allow the database application to find data fast; without reading.
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
Bend SQL to Your Will With EXPLAIN Ligaya Turmelle MySQL Support Engineer
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
Information Retrieval in Practice
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL
Chapter 8 Working with Databases and MySQL
Index Note: A bolded number or letter refers to an entire lesson or appendix. A Adding Data Through a View ADD_MONTHS Function 03-22, 03-23,
Contents Preface I Introduction Lesson Objectives I-2
Chapter 11 Managing Databases with SQL Server 2000
Introduction to SQL Server and the Structure Query Language
Presentation transcript:

® npr.org Migration From Oracle to MySQL An NPR Case Study By Joanne Garlow

Overview Background Database Architecture SQL Differences Concurrency Issues Useful MySQL Tools Encoding Gotchas

Background NPR (National Public Radio) Leading producer and distributor of radio programming All Things Considered, Morning Edition, Fresh Air, Wait, Wait, Dont Tell Me, etc. Broadcasted on over 800 local radio stations nationwide NPR Digital Media Website (NPR.org) with audio content from radio programs Web-Only content including blogs, slideshows, editorial columns About 250 produced podcasts, with over 600 in directory Mobile apps and sites Syndication

High-Level System Architecture

Limitations of the Oracle Architecture Reached capacity of single system to support our load Replication outside our budget Databases crashes were becoming frequent

Database Architecture Goals Redundancy Scalability Load balancing Separation of concerns Better security

High-Level System Architecture

Updated by our Content Management System Transaction Oriented Resource Contention Highly Normalized Isolation from main website Read-only by our webservers Horizontally scalable Database Architecture Main InnoDB AMG MyISAM PUBLIC InnoDB STATIONS InnoDB Main RO slave Main RO slave Content Mgmt System Web Servers Scripts Backup RO slave Read and updated only by our website Low resource contention Small tables or log tables Short Transactions Updated by a nightly script Read-only by our Content Management System Need fast full text queries (replacing Oracle Text) Large tables Updated by a quarterly script Read-only from our website Some log type information written Low resource contention No transactions

Issues When Converting SQL MySQL is case sensitive Oracle outer join syntax (+) -> OUTER JOIN clause Oracle returns a zero to indicate zero rows updated – MySQL returns TRUE (1) to indicate it successfully updated 0 rows MySQL sorts null to the top, Oracle sorts null to the bottom Use order by – colName desc for sorting asc with nulls at bottom MySQL has Limit clause – YAY! No sequences - DOH! Continued….

Replacing Oracle Sequences Initialize a table with a single row: CREATE TABLE our_seq ( id INT NOT NULL ); INSERT INTO our_seq (id) VALUES ( ); Do the following to get the next number in the sequence: UPDATE our_seq SET id=LAST_INSERT_ID(id+1); SELECT LAST_INSERT_ID();

Replacing Oracle Sequences For updating many rows at once, get the total number of unique IDs you need first: := COUNT(*) FROM... Then update npr_seq by that many rows: UPDATE npr_seq SET and store that ID into another variable: := LAST_INSERT_ID(); Then use the whole rownum workaround described above to get a unique value for each row: INSERT INTO my_table (my_primary_id... ) - FROM r,...

Converting Functions NVL() -> IFNULL() or COALESCE() DECODE() -> CASE() or IF() Concatenating strings || -> CONCAT() test || null returns test in Oracle CONCAT(test,null) returns null in MySQL LTRIM and RTRIM -> TRIM() INSTR() works differently. Use LOCATE() for Oracles INSTR() with occurrences = 1. SUBSTRING_INDEX() and REVERSE() might also work.

Converting Dates sysdate -> now() Adding or subtracting In Oracle – 1 subtracts a day In MySQL - 1 subtracts a milisecond – must useinterval TRUNC() -> DATE() TO_DATE and TO_CHAR -> STR_TO_DATE and DATE_FORMAT

Update Differences You can't update a table that is used in the WHERE clause for the update (usually in an "EXISTS" or a subselect) in mysql. UPDATE tableA SET tableA.col1 = NULL WHERE tableA.col2 IN (SELECT tableA.col2 FROM tableA A2, tableB WHERE tableB.col3 = A2.col3 AND tableB.col4 = ); You can join tables in an update like this (Much easier!): UPDATE tableA INNER JOIN tableB ON tableB.col3 = tableA.col3 SET tableA.col1 = NULL WHERE tableB.col4 = ;

RANK() and DENSE_RANK() We really found no good MySQL equivalent for these functions We used GROUP_CONCAT() with an ORDER BY and GROUP BY to get a list in a single column over a window of data

Collation You can set collation at the server, database, table or column level. Changing the collation at a higher level (say on the database) wont change the collation for preexisting tables or column. Backups will use the original collation unless you specify all the way down to column level.

Concurrency Issues In our first round of concurrency testing, our system ground to a halt! Deadlocks Slow Queries MySQL configuration sync_binlog = 1 // sync to disk, slow but safe innodb_flush_log_at_trx_commit = 1 // write each commit transaction_isolation = READ-COMMITTED

Useful MySQL Tools MySQL Enterprise Monitor MySQL GUI Tools Bundle: MySQL Query Browser similar to Oracles SQL Developer MySQL Administrator

Innotop and innoDB Status innotop Helped us identify deadlocks and slow queries (dont forget the slow query log!) In mysql, use show engine innodb status\G; Useful for contention and locking issues

Query Profiling Try the Query Profiler with Explain Plan when debugging slow queries query-profiler.html

Concurrency Solution Tuning our SQL and our server configuration helped Turns out that the RAID card we were using had no write cache at all. Fixing that allowed us to go live.

Encoding Gotchas Switched from ISO to UTF-8 Migration Tool Issues with characters that actually were not ISO in our Oracle database Lack of documentation for the LUA script produced by the migration GUI Update encoding end to end JSPs, scripts (Perl), PHP, tomcat (Java)

Continuing Issues Bugs with innodb locking specific records (as opposed to gaps before records) Uncommitted but timed out transactions Use innotop or show engine innodb status\G; and look for threads waiting for a lock but no locks blocking them Requires MySQL reboot

Questions? Joanne Garlow