Your SlideShare is downloading. ×
0
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Download Presentation
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Download Presentation

437

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
437
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • 2 1
  • Transcript

    • 1. Everything You Ever Wanted to Know About Migrating From Informix to DB2 * But were afraid to ask J.Warren Donovan Bob Carts
    • 2. Everything You Ever Wanted to Know About Migrating from Informix to DB2 <ul><li>Bob Carts </li></ul><ul><li>Senior Data Engineer, SAIC </li></ul><ul><li>[email_address] </li></ul><ul><li>J. Warren Donovan </li></ul><ul><li>Senior Software Engineer, SAIC </li></ul><ul><li>[email_address] </li></ul>
    • 3. About SAIC <ul><li>42,000 Employees </li></ul><ul><li>Headquarters in San Diego </li></ul><ul><li>Largest Site is Washington, DC Area </li></ul><ul><li>Majority of Work is Federal </li></ul><ul><li>www.saic.com </li></ul>
    • 4. About Us <ul><li>Certified Informix DBAs </li></ul><ul><li>Certified DB2 DBAs </li></ul><ul><li>WAIUG Board of Directors </li></ul><ul><li>Windows and UNIX (Solaris, IBM AIX, HP-UX) </li></ul><ul><li>IDS 7.31, 9.21, 9.3, XPS 8.31, DB2 8.1 </li></ul><ul><li>Data Warehouse and OLTP Applications </li></ul>
    • 5. About Our Project <ul><li>Data Warehouse </li></ul><ul><li>Multi-Node </li></ul><ul><li>1800+ Aggressive Users </li></ul><ul><li>600+ DSS Queries per day </li></ul><ul><li>Converted from Informix XPS version 8.31 to DB2 version 8.1 </li></ul><ul><li>900 GB of data </li></ul><ul><li>684 pieces of ETL code </li></ul><ul><li>ETL code SQL, KSH, PERL </li></ul>
    • 6. What is in this Session? <ul><li>Goal: To provide basic information on differences between Informix and DB2 SQL to help you get started in evaluating, planning or executing a conversion </li></ul><ul><li>Assumption: </li></ul><ul><ul><li>You are familiar with Informix </li></ul></ul><ul><li>Included:HOW to migrate </li></ul><ul><li>Not Included:WHY …or why not </li></ul>
    • 7. What is in this Session? <ul><li>Will cover: </li></ul><ul><ul><li>Converting DDL </li></ul></ul><ul><ul><li>Creating disk / tablespace structures </li></ul></ul><ul><ul><li>Creating Memory Structures </li></ul></ul><ul><ul><li>Basic Configuration / Tuning and, </li></ul></ul><ul><ul><li>Migration of SQL Code </li></ul></ul>
    • 8. Similarities of Informix and DB2 <ul><li>Relational Databases </li></ul><ul><li>Both owned by IBM </li></ul><ul><li>Both available for most platforms </li></ul><ul><li>Connect to a wide variety of front ends </li></ul>
    • 9. Product Differences <ul><li>INFORMIX </li></ul><ul><li>Different products for different uses </li></ul><ul><li>Simple configuration </li></ul><ul><li>Simple performance tuning </li></ul><ul><li>DB2 </li></ul><ul><li>“ One product fits all” </li></ul><ul><li>Complex configuration options </li></ul><ul><li>Advanced and robust performance tuning toolset </li></ul><ul><li>Will still exist in 10 years </li></ul>
    • 10. Definitions – Some DB2 Speak <ul><li>DBSpaces = Tablespaces </li></ul><ul><li>Chunks = Containers </li></ul><ul><li>Coservers = Logical Partitions </li></ul><ul><li>Logical Partitions are the biggest difference between Informix 7.x / Informix 9.x and DB2. </li></ul>
    • 11. What’s a Logical Partition? <ul><li>A virtual Database server </li></ul><ul><li>A DB2 Database uses Logical Partitions (or LPs) to maximize parallel processing by spreading data across I/O and CPUs </li></ul><ul><li>LPs can be used to spread data across multiple physical servers </li></ul><ul><li>Can be used to overcome tablespace size limitations </li></ul><ul><li>Can be used to overcome 2GB Memory Limitations of 32-bit installs </li></ul><ul><li>Before you do anything, decide if you will be using a Single or Multiple LP install! </li></ul>
    • 12. Informix vs. DB2 Structure Informix System Instances Buffers MGM Memory DBspaces Tables Indexes Tables Indexes Databases SHEAPTHRES Memory Tables Indexes Tables Indexes Databases Instances DB2 System Tblspaces Buffers Buffers Tblspaces
    • 13. Warren’s Setup Order <ul><li>From Informix </li></ul><ul><li>Layout Disk ( create space for binaries - minimum ) </li></ul><ul><li>Install Informix </li></ul><ul><li>Setup onconfig </li></ul><ul><li>Start instance </li></ul><ul><li>Create database </li></ul><ul><li>Create dbspaces </li></ul><ul><li>Update / Run DDL </li></ul><ul><li>Load Data </li></ul><ul><li>To DB2 </li></ul><ul><li>Layout Disk ( create space for binaries and DB at minimum ) </li></ul><ul><li>Install DB2 </li></ul><ul><li>Start Instance </li></ul><ul><li>Setup DBM CFG </li></ul><ul><li>Create database </li></ul><ul><li>Setup DB CFG </li></ul><ul><li>Create memory structures </li></ul><ul><li>Create tablespaces </li></ul><ul><li>Update / Run DDL </li></ul><ul><li>Load Data </li></ul>
    • 14. Warren ’ s DB2 Migration Order <ul><li>From Informix To DB2 </li></ul><ul><li>Pick DB2 installation: Single or Multi Partition </li></ul><ul><li>Get Informix DDL – Convert to DB2 </li></ul><ul><li>Analyze DDL for Tablespace Structure </li></ul><ul><li>Create DDL for Tablespaces </li></ul><ul><li>Analyze Tablespaces for Memory Structure </li></ul><ul><li>Create Memory DDL </li></ul><ul><li>Create Instance </li></ul><ul><li>Create Database </li></ul><ul><li>Update / Run DDL </li></ul><ul><li>Load Data </li></ul><ul><li>Monitor and Tune Database </li></ul>
    • 15. Migrating DDL <ul><li>The first step is to rewrite Informix DDL to DB2 </li></ul><ul><li>Get Informix DDL using dbschema </li></ul><ul><li>Data types, Primary and Secondary keys remarkably similar </li></ul><ul><li>Extent sizes, Indexes, Fragmentation/Partitioning are not. </li></ul><ul><li>Know what tables you want together, and if you will install a Single or Multiple Partition DB2 instance </li></ul>
    • 16. Creating Tables Comparison <ul><li>INFORMIX </li></ul><ul><li>Can set initial and next extent sizes </li></ul><ul><li>Can fragment across dbspaces </li></ul><ul><li>Fragment by round-robin, expression + hash </li></ul><ul><li>Can create indexes later in any dbspace </li></ul><ul><li>DB2 </li></ul><ul><li>Extent size set by tablespace </li></ul><ul><li>1 Table to 1 Tablespace </li></ul><ul><li>Hash fragment in multi-partition, round-robin automatic in a tablespace with multiple containers </li></ul><ul><li>Set index location in create table statement </li></ul>
    • 17. Creating Tables <ul><li>Basically, all the same data types </li></ul><ul><li>One table – one tablespace </li></ul><ul><li>Must specify index location during create table statement </li></ul><ul><li>If you’ll ever need to do unlogged updates or inserts, use the “not logged initially” option </li></ul><ul><li>A Partitioning Key is a good idea, especially if creating the table in a tablespace with containers that span multiple Logical Partitions </li></ul>
    • 18. Informix Create Table Statement <ul><li>CREATE TABLE NHL.PLAYERS ( </li></ul><ul><li>NAME CHAR(20) , </li></ul><ul><li>TEAM VARCHAR (20) </li></ul><ul><li>GOALS INTEGER , </li></ul><ul><li>ASSISTS INTEGER , </li></ul><ul><li>ID_NUMBER INTEGER ) </li></ul><ul><li>FRAGMENT BY ROUND ROBIN IN bigspace </li></ul><ul><li>EXTENT SIZE 10000 NEXT SIZE 1000; </li></ul>
    • 19. DB2 Create Table Statement <ul><li>CREATE TABLE NHL.PLAYERS ( </li></ul><ul><li>NAME CHAR(20) , </li></ul><ul><li>TEAM VARCHAR (20) </li></ul><ul><li>GOALS INTEGER , </li></ul><ul><li>ASSISTS INTEGER , </li></ul><ul><li>ID_NUMBER INTEGER ) </li></ul><ul><li>PARTITIONING KEY (ID_NUMBER) </li></ul><ul><li>IN BIGSPACE_1 INDEX IN BIG_INDEX_1 NOT LOGGED INITIALLY ; </li></ul>
    • 20. About Partitioning Keys <ul><li>The more diverse the data in a field, and the more it is used in joins, the better </li></ul><ul><li>Defaults to PK (first column if no PK) </li></ul><ul><li>Greatest performance boost is from co-located joins: when it can join to another table on the same key, and can therefore ignore whole containers </li></ul>
    • 21. Creating Indexes <ul><li>You WILL need indexes </li></ul><ul><li>Location is determined during table definition </li></ul><ul><li>Be sure to use the ALLOW REVERSE SCANS parameter </li></ul><ul><li>Can use the db2advis tool to recommend indexes </li></ul>
    • 22. Sample DB2 Create Index Statement <ul><li>CREATE INDEX NHL.PLAY_ID ON NHL.PLAYERS (ID_NUMBER ASC) </li></ul><ul><li>PCTFREE 5 ALLOW REVERSE SCANS; </li></ul>
    • 23. With Tables Ready… Time to Setup Tablespaces <ul><li>Once table DDL is complete, analyze it for tablespaces </li></ul><ul><li>One table fits into one and ONLY one tablespace </li></ul><ul><li>Tablespaces can hold multiple tables </li></ul><ul><li>Tablespaces must have one, and only one, memory buffer pool </li></ul>
    • 24. Informix Dbspaces vs DB2 Tablespaces <ul><li>DBspaces </li></ul><ul><li>Raw Devices, Cooked </li></ul><ul><li>Can add chunks </li></ul><ul><li>Writes consecutively to chunks </li></ul><ul><li>Tables can be fragmented across DBSpaces </li></ul><ul><li>Extents set at TABLE creation time </li></ul><ul><li>Can offset in raw devices </li></ul><ul><li>Can mirror at DB level </li></ul><ul><li>Tablespaces </li></ul><ul><li>DMS Raw,DMS Cooked,and SMS </li></ul><ul><li>Can add containers </li></ul><ul><li>Automatically balances data across containers </li></ul><ul><li>1 Table to 1 Tablespace </li></ul><ul><li>Extents set at tablespace level </li></ul><ul><li>Cannot offset in raw devices </li></ul><ul><li>No DB mirroring </li></ul>
    • 25. Initial Disk Layout <ul><li>DB2 has 3 types of tablespaces </li></ul><ul><li>System Managed Space (for database, tempspace and blob/clobs) </li></ul><ul><li>Raw Database Managed Space (DMS Raw) </li></ul><ul><li>“ Cooked” Database Managed Space (DMS Cooked) </li></ul><ul><li>Know when to use which, and why! </li></ul><ul><li>DB2 has no internal DB mirroring: use OS mirroring. </li></ul><ul><li>DB2 cannot set offsets on raw devices: one container to one raw device </li></ul>
    • 26. Maximum Tablespace Sizes <ul><li>True for all tablespace types </li></ul><ul><li>Max size per logical partition the tablespace spans: </li></ul><ul><ul><li>With 4KB pages– 64GB </li></ul></ul><ul><ul><li>With 8KB pages– 128GB </li></ul></ul><ul><ul><li>With 16KB pages – 256GB </li></ul></ul><ul><ul><li>With 32KB pages – 512GB </li></ul></ul><ul><li>Max of 255 rows per page </li></ul>
    • 27. Choosing a Tablespace type <ul><li>DMS </li></ul><ul><li>Fastest </li></ul><ul><li>Can add containers </li></ul><ul><li>Cannot contain LOBs </li></ul><ul><li>SMS </li></ul><ul><li>Very flexible, very easy to set up </li></ul><ul><li>Cannot add containers </li></ul><ul><li>Can contain LOBs </li></ul>
    • 28. Creating a simple DMS Raw Tablespace <ul><li>CREATE REGULAR TABLESPACE REFERENCE IN DATABASE PARTITION GROUP REF_GRP PAGESIZE 8192 MANAGED BY DATABASE </li></ul><ul><li>USING (DEVICE '/dev/reference_part1'131072) ON DBPARTITIONNUMS (1) </li></ul><ul><li>EXTENTSIZE 240 </li></ul><ul><li>PREFETCHSIZE 240 </li></ul><ul><li>BUFFERPOOL REF_8K </li></ul><ul><li>OVERHEAD 12.500000 </li></ul><ul><li>TRANSFERRATE 0.300000; </li></ul>
    • 29. Creating a simple DMS Cooked Tablespace <ul><li>CREATE REGULAR TABLESPACE REF2 IN DATABASE PARTITION GROUP REF_GRP PAGESIZE 8192 MANAGED BY DATABASE </li></ul><ul><li>USING (FILE '/dev/ref2_part1.dat'131072) ON DBPARTITIONNUMS (1) </li></ul><ul><li>EXTENTSIZE 240 </li></ul><ul><li>PREFETCHSIZE 240 </li></ul><ul><li>BUFFERPOOL REF_8K </li></ul><ul><li>OVERHEAD 12.500000 </li></ul><ul><li>TRANSFERRATE 0.300000; </li></ul>
    • 30. DMS Tablespaces: Things to keep in mind <ul><li>Never use them for system catalogs </li></ul><ul><li>For RAW: No offsets available: set your raw device to exactly the size you need </li></ul><ul><li>No DB mirroring: mirror disk at OS level </li></ul><ul><li>Cooked slightly more flexible, slightly slower </li></ul><ul><li>When using multiple containers, make your container sizes the same for load and data balancing! </li></ul><ul><li>Monitor with the “db2 list tablespaces show detail command” </li></ul>
    • 31. Monitoring DMS Tablespaces <ul><li>db2 list tablespaces show detail </li></ul><ul><li>Tablespace ID = 5 </li></ul><ul><li>Name = BIGSPACE_1 </li></ul><ul><li>Type = Database managed space </li></ul><ul><li>Contents = Any data </li></ul><ul><li>State = 0x0000 </li></ul><ul><li>Detailed explanation: </li></ul><ul><li>Normal </li></ul><ul><li>Total pages = 4587520 </li></ul><ul><li>Useable pages = 4587120 </li></ul><ul><li>Used pages = 3137520 </li></ul><ul><li>Free pages = 1449600 </li></ul><ul><li>High water mark (pages) = 4474560 </li></ul><ul><li>Page size (bytes) = 8192 </li></ul><ul><li>Extent size (pages) = 240 </li></ul><ul><li>Prefetch size (pages) = 240 </li></ul><ul><li>Number of containers = 1 </li></ul>
    • 32. Creating an SMS Tablespace <ul><li>CREATE temporary TABLESPACE TEMP2_8K IN DATABASE PARTITION GROUP IBMTEMPGROUP PAGESIZE 8192 MANAGED BY SYSTEM </li></ul><ul><li>USING ('/temp1_jfs2/tmp1_1') on nodes(1) </li></ul><ul><li>USING ('/temp2_jfs2/tmp2_1') on nodes(2) </li></ul><ul><li>USING ('/temp3_jfs2/tmp3_1') on nodes(3) </li></ul><ul><li>USING ('/temp4_jfs2/tmp4_1') on nodes(4) </li></ul><ul><li>EXTENTSIZE 24 PREFETCHSIZE 72 </li></ul><ul><li>BUFFERPOOL TEMP_8K </li></ul><ul><li>OVERHEAD 12.500000 </li></ul><ul><li>TRANSFERRATE 0.300000 </li></ul>
    • 33. SMS Tablespaces: Things to keep in mind <ul><li>Slowest </li></ul><ul><li>Ideal for system catalogs </li></ul><ul><li>Ideal for tempspace </li></ul><ul><li>Easy to set up, minimal planning as they Expand and Contract as required </li></ul><ul><li>Cannot expand or add containers </li></ul><ul><li>Monitor by watching the filespace fill and empty </li></ul>
    • 34. Monitoring SMS Tablespaces <ul><li>db2 list tablespaces show detail – always listed as full, so watch file system too </li></ul><ul><li>Tablespace ID = 9 </li></ul><ul><li>Name = TTMP_8K </li></ul><ul><li>Type = System managed space </li></ul><ul><li>Contents = System Temporary data </li></ul><ul><li>State = 0x0000 </li></ul><ul><li>Detailed explanation: </li></ul><ul><li>Normal </li></ul><ul><li>Total pages = 18689 </li></ul><ul><li>Useable pages = 18689 </li></ul><ul><li>Used pages = 18689 </li></ul><ul><li>Free pages = Not applicable </li></ul><ul><li>High water mark (pages) = Not applicable </li></ul><ul><li>Page size (bytes) = 8192 </li></ul><ul><li>Extent size (pages) = 240 </li></ul><ul><li>Prefetch size (pages) = 240 </li></ul><ul><li>Number of containers = 1 </li></ul>
    • 35. Some Critical Notes on Tablespaces <ul><li>Some parameters not seen in Informix: </li></ul><ul><li>EXTENT SIZE – The extent size for all tables in this tablespace </li></ul><ul><li>PREFETCH SIZE – Pages grabbed at a time </li></ul><ul><li>BUFFERPOOL – name of the bufferpool the tablespace will use. Must exist before table can be created, can be changed </li></ul><ul><li>OVERHEAD, TRANSFERRATE – Indicators of the speed of the disk the tablespace uses. Affects the optimizer </li></ul>
    • 36. From Tablespaces to Memory <ul><li>Before you can create tablespaces, you will need bufferpools with the same page size to dedicate them to </li></ul><ul><li>Can just use the default: IBMDEFAULTBP </li></ul><ul><li>Can create specific buffers later, and change with the “alter tablespace” command </li></ul><ul><li>Can never change the page size of an existing tablespace </li></ul>
    • 37. Differences in Memory <ul><li>INFORMIX </li></ul><ul><li>BUFFERS </li></ul><ul><li>SHMVIRTSIZE </li></ul><ul><li>SHMTOTAL </li></ul><ul><li>DS_TOTAL_MEMORY </li></ul><ul><li>Log, backup buffers, etc. </li></ul><ul><li>(Resident, Virtual and Message) </li></ul><ul><li>DB2 </li></ul><ul><li>BUFFPAGE </li></ul><ul><li>Custom Bufferpools </li></ul><ul><li>SHEAPTHRES </li></ul><ul><li>SORTHEAP </li></ul><ul><li>Lots of log, backup and other little buffers </li></ul>
    • 38. DB2 Bufferpool Basics <ul><li>Comes with a default IBMDEFAULTBP </li></ul><ul><li>Can create different buffer pools, with different page sizes, for different tablespaces and data </li></ul><ul><li>IBM doesn’t recommend using more than 2 different page sizes </li></ul><ul><li>Created in the database you are currently connected to </li></ul>
    • 39. Creating Bufferpools <ul><li>This creates an 8K Bufferpool </li></ul><ul><li>CREATE BUFFERPOOL M2_8K SIZE 175000 PAGESIZE 8192 NOT EXTENDED STORAGE; </li></ul><ul><li>In a Multi-Partition install, it is created across all partitions </li></ul><ul><li>Total size will be: </li></ul><ul><li>SIZE * ( number of LPs) </li></ul>
    • 40. Some BUFFERPOOL Recommendations <ul><li>Expand the default BUFFER with the alter bufferpool command </li></ul><ul><li>First try 1 big buffer for all your tablespaces…this will probably be fine </li></ul><ul><li>Experiment with the following: </li></ul><ul><ul><li>Create small bufferpools for reference tables </li></ul></ul><ul><ul><li>If you have a small number of large, busy tables, create bufferpools for each </li></ul></ul><ul><ul><li>Try creating a separate bufferpool for tempspace </li></ul></ul>
    • 41. Let’s git it on! <ul><li>Now that we know what Bufferpools, Tablespaces and Tables we need…let’s install and configure DB2! </li></ul><ul><li>But there’s a few things we’ll want to do first… </li></ul>
    • 42. Layout Disk for Binaries and System Catalogs <ul><li>Create a filesystem directory structure to install the binaries </li></ul><ul><li>Create a filesystem to contain the system catalogs (the database) </li></ul><ul><li>Keep them separate from disk you plan to put data on </li></ul><ul><li>DB2 has no internal DB mirroring: use OS mirroring </li></ul>
    • 43. Layout Disk For Tablespaces <ul><li>DB2 has 3 types of tablespaces, with different disk requirements </li></ul><ul><li>System Managed Space – Requires a filesystem directory structure for each path </li></ul><ul><li>DMS Raw – Requires raw devices for each container </li></ul><ul><li>DMS Cooked – Requires a filesystem directory structure to create containers in </li></ul><ul><li>Know when to use which, and why! </li></ul>
    • 44. Differences in Install and Initial Configuration <ul><li>INFORMIX </li></ul><ul><li>Onconfig </li></ul><ul><li>Sqlhosts </li></ul><ul><li>Informix.rc </li></ul><ul><li>DB2 </li></ul><ul><li>Database Manager Configuration (DBM Config) </li></ul><ul><li>Database Config (DB Config) </li></ul><ul><li>.rhosts </li></ul><ul><li>Db2set </li></ul>
    • 45. Install DB2 Binaries <ul><li>Very similar to Informix install: RTFM! (Read the fine Manual) </li></ul><ul><li>For DB2 Multi-Partition Installs: requires that binaries be installed on each PHYSICAL node </li></ul><ul><li>Multi-Partition also requires creation of the db2nodes.cfg file before startup </li></ul>
    • 46. Example db2nodes.cfg file <ul><li>Located in $db2home/sqllib </li></ul><ul><li>Per P690 Red Book: 1 LP per CPU – I think this is excessive. </li></ul><ul><li>3 Columns: Absolute LP number, Name of Physical Node, Number on Physical Node </li></ul><ul><li>1 dbserver1 0 </li></ul><ul><li>2 dbserver1 1 </li></ul><ul><li>3 dbserver2 0 </li></ul><ul><li>4 dbserver2 1 </li></ul>
    • 47. Starting DB2 <ul><li>As the database owner, just run: </li></ul><ul><li>db2start </li></ul>
    • 48. Setting up the DBM Config <ul><li>1 per instance </li></ul><ul><li>db2 get dbm cfg (for current settings) </li></ul><ul><li>Cannot change with editor </li></ul><ul><li>To Update: </li></ul><ul><ul><li>db2 update dbm cfg using <param> <value> </li></ul></ul><ul><li>Changes affects the instance, and therefore all databases in the instance </li></ul><ul><li>Some changes take effect immediately, most require a db2stop and db2start </li></ul>
    • 49. DBM Config Parameters <ul><li>DFTDBPATH </li></ul><ul><li>INTRA_PARALLEL </li></ul><ul><li>SHEAPTHRES </li></ul><ul><li>MONITOR SWITCHES (Buffer Pool, Lock, Sort, Statement,Table, Timestamp, Unit of Work and the killer Health Monitor) </li></ul><ul><li>SVCENAME </li></ul><ul><li>Backup, restore and audit buffers </li></ul>
    • 50. Creating a Database <ul><li>INFORMIX </li></ul><ul><li>Location defaults to rootspace (defined in config) </li></ul><ul><li>Put in dbspace </li></ul><ul><li>Dbspace must exist </li></ul><ul><li>Raw space for best performance </li></ul><ul><li>DB2 </li></ul><ul><li>Location defaults to DFLTDBPATH in DBM CFG </li></ul><ul><li>Put in OS path </li></ul><ul><li>Path must exist </li></ul><ul><li>System Managed Space for best performance </li></ul>
    • 51. Create Database Script <ul><li>create database nhl_mart on /db2ins07/db2ese </li></ul><ul><li>catalog tablespace managed by system using ('/nhl_mart/syscat/nhl_sys'); </li></ul>
    • 52. DB Config <ul><li>One per database </li></ul><ul><li>Cannot change with editor </li></ul><ul><li>db2 get db cfg for <dbname> </li></ul><ul><li>To update on a single partition server: </li></ul><ul><ul><li>db2 update db cfg for <dbname> using <param> <value> </li></ul></ul><ul><li>To update on a multi partition server: </li></ul><ul><ul><li>db2_all db2 update db cfg for <dbname> using <param> <value> </li></ul></ul>
    • 53. DB Config Parameters <ul><li>BUFFPAGE – default bufferpool </li></ul><ul><li>SORTHEAP – </li></ul><ul><li>AVG_APPLS </li></ul><ul><li>LOGFILSIZE, LOGPRIMARY, LOGSECOND and NEWLOGPATH </li></ul><ul><li>DFT_QUERYOPT – 1-9 </li></ul><ul><li>LOGBUFSZ </li></ul>
    • 54. Extra Step for Multi-Partition Setup <ul><li>If doing a multi-partition install, you will want to setup Partition Groups…since you probably don’t need all your data spread across every node! </li></ul><ul><li>CREATE DATABASE PARTITION GROUP &quot;BIG_PART&quot; ON DBPARTITIONNUMS </li></ul><ul><li>(1,2,3,4); </li></ul><ul><li>CREATE DATABASE PARTITION GROUP &quot;REF_PART&quot; ON DBPARTITIONNUMS </li></ul><ul><li>(1); </li></ul>
    • 55. Setting Up Logs <ul><li>For performance, recommend setting up all logs as LOGPRIMARY </li></ul><ul><li>Try to place logs on disk not used for other activities. Set a new path with the NEWLOGPATH param, then bounce engine </li></ul><ul><li>Circular logging is a new feature </li></ul>
    • 56. SHEAPTHRES: Major DB2 Memory Considerations <ul><li>Do you do a lot sorting in this instance?…this database? </li></ul><ul><li>Do you anticipate (or observe) large overflows to tempspace? </li></ul><ul><li>Are you frequently reading large volumes of data from 2 or more tables? </li></ul><ul><li>If you answer YES to these questions, you may need SHEAPTHRES: SORT MEMORY </li></ul>
    • 57. What is SORT HEAP? <ul><li>Individual rows are written to BUFFERS in each database </li></ul><ul><li>All sorts are done in a memory pool called the Sort Heap </li></ul><ul><li>SHEAPTHRES -a DBM parameter used to set an instance wide max sort heap </li></ul><ul><li>SORTHEAP – A DB parameter used by each database to determines how much Sort Heap a single query can use within that database </li></ul>
    • 58. SHEAPTHRES / SORT HEAP recommendations <ul><li>Make sure SHEAPTHRES + BUFFERPOOLS is less than system memory </li></ul><ul><li>Start small – adding to SHEAPTHRES will require a reduction of BUFFERPOOLS </li></ul><ul><li>Capture SQL and monitor queries to gauge SORT OVERFLOWS </li></ul><ul><li>Set the SORTHEAP to fit evenly into SHEAPTHRES </li></ul><ul><li>When the SORTHEAP overflows to temp buffers, it writes the entire SORTHEAP. So, a large SORTHEAP may actually hurt performance! </li></ul>
    • 59. Some Basic Monitoring <ul><li>To get any useful information, you must turn on the Monitor Switches in the DBM CFG </li></ul><ul><li>Use “db2 list applications” to get the Appl. Handle number </li></ul><ul><li>Use “db2 get snapshot for application <Appl. Handle number>” for all information about that query </li></ul>
    • 60. Some Get Snapshot Output <ul><li>The output is much too extensive to review entirely, but here’s some interesting stuff that’s in it: </li></ul><ul><li>Dynamic SQL statement text </li></ul><ul><li>Sort Overflows </li></ul><ul><li>Rows Read, Rows Written </li></ul><ul><li>Bufferpool Data Logical Reads </li></ul>
    • 61. Some Cool Tools <ul><li>Materialized Query Tables: MQTs </li></ul><ul><li>Index Advisor: db2advis </li></ul><ul><li>Db2shema - db2look </li></ul><ul><li>GETDISTRIB –Checking your Data Distribution </li></ul>
    • 62. What’s an MQT <ul><li>A Materialized Query Table is like a summary table that is automatically referenced </li></ul><ul><li>Can be costly to build in terms of processing time and disk </li></ul><ul><li>If designed properly, can significantly reduce processing time on many reports by effectively having the results already processed. </li></ul>
    • 63. Example MQT <ul><li>CREATE TABLE CORP.MQT_SALES AS ( SELECT STORE_NO, EMPNO, CUSTNO, </li></ul><ul><li>SUM(SALE_PRICE_RAW) as sale_price_raw, </li></ul><ul><li>SUM(COMMISSIONS) as commissions_paid_tot, </li></ul><ul><li>SUM(COST_OF_GOODS) as cost_of_goods_raw, </li></ul><ul><li>SUM(SALES_TAX) as sales_tax_tot </li></ul><ul><li>FROM CORP.SALES GROUP BY STORE_NO, EMPNO, CUSTNO) </li></ul><ul><li>data initially deferred refresh immediate ENABLE QUERY OPTIMIZATION </li></ul><ul><li>MAINTAINED BY SYSTEM </li></ul><ul><li>partitioning key (store_no) in bigspace_2 not logged </li></ul><ul><li>initially; </li></ul><ul><li>commit; </li></ul><ul><li>update command options using c off; </li></ul><ul><li>alter table CORP.MQT_SALES activate not logged initially; </li></ul><ul><li>REFRESH TABLE M2ADM.MQT_SALES NOT INCREMENTAL; </li></ul>
    • 64. Defining Indexes with DB2 Advis <ul><li>Use the DB2 Advis utility to analyze SQL statements for indexes </li></ul><ul><li>First capture a SQL statement that is exhibiting poor performance </li></ul><ul><li>Write it to file, say trouble.sql </li></ul><ul><li>Run db2advis –d <dbname> -i <filename> -o <output file> </li></ul><ul><li>Example: </li></ul><ul><li>db2advis –d testdb –i trouble.sql –o fix.out </li></ul>
    • 65. DB2 Advis Output <ul><li>Will output an estimate (in timerons) to run the query with and without the recommended indexes </li></ul><ul><li>Will output indexes (if any will help) </li></ul><ul><li>Remember to add ALLOW REVERSE SCANS to the create index statements! </li></ul>
    • 66. DB2LOOK <ul><li>Use the DB2LOOK tool to output a schema, or physical layout </li></ul><ul><li>To get all options: </li></ul><ul><ul><li>db2look ? </li></ul></ul><ul><li>The following would output all the DDL needed to recreate the test database to a file called test.ddl </li></ul><ul><li>db2look –d test –e –l –o test.ddl </li></ul>
    • 67. GETDISTRIB – Check distribution of a table <ul><li>Use the GETDISTRIB from the db2 prompt to output the distribution of the data in a table </li></ul><ul><li>Syntax: getdistrib <tablename> <field> </li></ul><ul><li>Example: getdistrib employee empno </li></ul><ul><li>Returns: 1) Partition Number 2) Rows </li></ul><ul><li>1 2 </li></ul><ul><li>----------- ----------- </li></ul><ul><li>1 151967 </li></ul><ul><li>2 138988 </li></ul><ul><li>3 193551 </li></ul><ul><li>4 162090 </li></ul>
    • 68. What are We Going to Do About All This Code?? <ul><li>Application code can be converted to DB2 </li></ul><ul><li>The question is: </li></ul><ul><ul><li>how to convert </li></ul></ul><ul><ul><li>how long will it take </li></ul></ul><ul><ul><li>how will performance be after conversion </li></ul></ul>
    • 69. What are We Going to Do About All This Code?? <ul><li>You will hear: </li></ul><ul><ul><li>SQL is SQL </li></ul></ul><ul><ul><li>Just Point the Application at DB2 </li></ul></ul><ul><ul><li>Just run the code through the conversion tool </li></ul></ul><ul><li>To estimate: </li></ul><ul><ul><li>Id all the code that will need to change (joins, group by, external table, truncate, etc) build an estimate, then at least double it ! </li></ul></ul>
    • 70. Some Things We Learned - Support <ul><li>Make friends with DB2 Developers in Toronto because the DB2 help desk does not answer SQL questions </li></ul><ul><li>DB2 SQL assistance is available for $ </li></ul><ul><li>Informix Help Desk Does answer SQL questions </li></ul>
    • 71. Some Things We Learned – Documentation <ul><li>DB2 documentation is on par or better than Informix documentation (and Informix documentation is pretty good!) </li></ul><ul><li>Improvements to the documentation are in the works (adding examples) </li></ul><ul><li>Look at IBM.com, DB2 Technical Support, Product Manuals </li></ul><ul><li>The manuals we use most: </li></ul><ul><ul><li>SQL reference Volumes 1 and 2 </li></ul></ul><ul><ul><li>Data Movement Utilities Guide and Reference </li></ul></ul>
    • 72. Some Things We Learned – Monitoring <ul><li>Informix “onstat” commands make for easy monitoring </li></ul><ul><li>While monitoring tools are available in DB2, they can be awkward </li></ul><ul><li>Onstat type monitoring commands are on the list to be added to DB2 in a future release </li></ul>
    • 73. Some Things We Learned – Monitoring <ul><li>Determine which processes are running: </li></ul><ul><ul><li>INFORMIX: Onstat –g ses/sql/act/ath </li></ul></ul><ul><ul><li>DB2: list applications show detail </li></ul></ul><ul><li>View a specific process: </li></ul><ul><ul><li>INFORMIX: onstat –g ses <PID> </li></ul></ul><ul><ul><li>DB2: get snapshot for application agentid <PID> </li></ul></ul><ul><li>Kill a process: </li></ul><ul><ul><li>INFORMIX: onmode –z <PID> </li></ul></ul><ul><ul><li>DB2: force application ‘(PID)’ or force application all </li></ul></ul>
    • 74. Some Things We Learned – Monitoring <ul><li>View the database configuration: </li></ul><ul><ul><li>INFORMIX: onstat –c </li></ul></ul><ul><ul><li>DB2: get database configuration and/or get database managers configuration (get db cfg / get db mgr cfg) </li></ul></ul><ul><li>View available tablespaces: </li></ul><ul><ul><li>INFORMIX: onstat –d/-D/-t/-T </li></ul></ul><ul><ul><li>DB2: list tablespace show detail </li></ul></ul>
    • 75. Interactive Access <ul><li>DBACCESS – Psuedo GUI, Menu bar driven </li></ul><ul><li>DB2 CLP (command line processor) – A little clumsy, but adequate. More like sybase or oracle interface </li></ul><ul><li>Getting Help </li></ul><ul><ul><li>Help dbaccess cntl-w </li></ul></ul><ul><ul><li>Help ? CLP Command </li></ul></ul><ul><li>Connecting </li></ul><ul><ul><li>Db2 initially requires an explicit connect </li></ul></ul><ul><ul><li>Informix implicitly connects when using dbaccess </li></ul></ul>
    • 76. DB2CLP <ul><li>Several ways to execute commands </li></ul><ul><ul><li>db2 <command> </li></ul></ul><ul><ul><li>Example: db2 connect to mydb </li></ul></ul><ul><li>You can also use interactive mode </li></ul><ul><ul><ul><li>db2 –t </li></ul></ul></ul><ul><ul><ul><li>Connect to mydb; </li></ul></ul></ul><ul><ul><ul><li>Select col1, col2 </li></ul></ul></ul><ul><ul><ul><li>From mytable; </li></ul></ul></ul><ul><ul><ul><li>Quit; </li></ul></ul></ul>
    • 77. DB2CLP <ul><li>You can execute OS commands within DB2 CLP </li></ul><ul><li>! Cp file1 file2 </li></ul><ul><li>Get a list of databases: </li></ul><ul><li>List active databases; </li></ul><ul><li>Get a list of columns: </li></ul><ul><li>List tables [for schema <schemaname>; </li></ul><ul><li>Get the layout of a table: </li></ul><ul><li>Describe table <schemaname>.<tablename>; </li></ul>
    • 78. Calling from ksh Script <ul><li>Dbaccess [dbname] <<EOF > stdout 2>stderror </li></ul><ul><li>Select bla bla bla; </li></ul><ul><li>EOF </li></ul><ul><li>Db2 –tvl <logfilename> <<EOF > </li></ul><ul><li>Connect to [dbname]; </li></ul><ul><li>Select bla bla bla </li></ul><ul><li>EOF </li></ul>
    • 79. A few little things… <ul><li>Default Permissions </li></ul><ul><ul><li>Informix: Public has permissions by default </li></ul></ul><ul><ul><li>DB2: public does not </li></ul></ul><ul><li>Updating Statistics (different syntax) </li></ul><ul><ul><li>Runstats on <schema>.<table> with distribution </li></ul></ul><ul><ul><li>And indexes all shrlevel change; </li></ul></ul><ul><li>Code Comments </li></ul><ul><ul><li>DB2 does support the dash dash for comments </li></ul></ul><ul><ul><li>However, they need to start in column #1 of a line </li></ul></ul><ul><ul><li>-- This works as a comment </li></ul></ul><ul><ul><li>somecol char(3) -- this does not </li></ul></ul>
    • 80. A few little things… <ul><li>Don’t use double quotes in DB2 ! </li></ul><ul><ul><li>Select * from tabname where name = ‘Bob’ </li></ul></ul><ul><li>DB2 does not support Directives </li></ul>
    • 81. Datatypes <ul><li>DB2 does not support implicit casting </li></ul><ul><li>Explicitly cast all data types in expressions </li></ul><ul><li>Example: </li></ul><ul><li>Create table bob.tabname (col1 integer,col2 char(10),col3 char(3))… </li></ul><ul><li>Insert into tabname values (null, ‘bob’, null) --informix </li></ul><ul><li>Insert into tabname values (cast(null as integer), ‘bob’, cast(null as char)) </li></ul>
    • 82. Limiting Number of Rows Returned/Optimize for Number of Rows <ul><li>Informix: Select first 100 ssn from people; </li></ul><ul><li>DB2: Select ssn from people </li></ul><ul><li>Fetch first 100 rows only; </li></ul><ul><li>Optimize for a particular number of rows (db2 only) </li></ul><ul><li>Db2: Select ssn from people </li></ul><ul><li>Optimize for 20 rows; </li></ul>
    • 83. Join Syntax <ul><li>DB2 Outer join syntax is different than Informix </li></ul><ul><li>DB2 is reportedly ANSI standard and Informix is not </li></ul>
    • 84. Join Syntax INFORMIX: Select a.name, a.employ_num, b.program, c.ed_level From employee a, training b, OUTER education c Where a.employ_num = b.employ_num and a.employ_num = c.employ_num and b.program = ‘DB2101’ DB2: Select a.name, a.employ_num, b.program, c.ed_level From employee a INNER JOIN training b on a.employ_num = b.employ_num LEFT OUTER JOIN education c on a.employ_num = c.employ_num Where b.program = ‘DB2101’
    • 85. Group by <ul><li>Can’t use “number” syntax </li></ul><ul><ul><li>Group by 1,2,3…. </li></ul></ul><ul><li>Forced to make case statements, etc redundant </li></ul>
    • 86. Group by - INFORMIX <ul><li>Select gender, state_of_birth, </li></ul><ul><li>Case when age > 19 and age < 31 then ‘Young’ </li></ul><ul><li>when age > 30 and age < 46 then ‘middle aged’ </li></ul><ul><li>when age > 46 then ‘Up there’ </li></ul><ul><li>End category </li></ul><ul><li>From employee </li></ul><ul><li>Group by 1,2,3 </li></ul>
    • 87. Group by – DB2 <ul><li>Select gender, state_of_birth, </li></ul><ul><li>Case when age > 19 and age < 31 then ‘Young’ </li></ul><ul><li>when age > 30 and age < 46 then ‘middle aged’ </li></ul><ul><li>when age > 46 then ‘Up there’ </li></ul><ul><li>End case </li></ul><ul><li>From employee </li></ul><ul><li>Group by gender, state_of_birth, </li></ul><ul><li>Case when age > 19 and age < 31 then ‘Young’ </li></ul><ul><li>when age > 30 and age < 46 then ‘middle aged’ </li></ul><ul><li>when age > 46 then ‘Up there’ </li></ul><ul><li>End case </li></ul>
    • 88. Having <ul><li>Syntax available in DB2 and not Informix </li></ul><ul><li>Look for duplicate keys </li></ul><ul><li>select * from people_table where ssn in </li></ul><ul><li>(select ssn from people_table </li></ul><ul><li>group by ssn having count(*) > 1 ); </li></ul>
    • 89. Alter Statements <ul><li>Alter capabilities are limited in DB2 </li></ul><ul><ul><li>Can’t drop a column </li></ul></ul><ul><ul><li>Can’t change a datatype for a column </li></ul></ul><ul><li>We of course used the alter – drop in our Informix Code! </li></ul>
    • 90. UnLogged Tables <ul><li>Using Unlogged databases in Informix is straight forward </li></ul><ul><li>Using Unlogged tables in db2 version 7.2 is </li></ul><ul><ul><li>Awkward </li></ul></ul><ul><ul><li>Temporary </li></ul></ul><ul><ul><li>Dangerous </li></ul></ul><ul><ul><li>Still Possible </li></ul></ul><ul><li>Db2 version 8.1 is less disastrous </li></ul><ul><li>Basic problem is auto rollback makes table permanently unavailable, must recreate or restore </li></ul>
    • 91. UnLogged Tables <ul><li>When creating a table must specify that logging can be turned off </li></ul><ul><ul><li>Create table bob.xyz </li></ul></ul><ul><ul><li>(Col1 char(2)) </li></ul></ul><ul><ul><li>In tablespace123 index in indexspace456 </li></ul></ul><ul><ul><li>Not logged initially; </li></ul></ul><ul><li>Must alter the table to temporarily turn logging off </li></ul><ul><ul><li>Update command options using c off; </li></ul></ul><ul><ul><li>Alter table bob.xyz activate not logged initially; </li></ul></ul><ul><ul><li>Insert into bob.xyz … </li></ul></ul><ul><ul><li>Commit; </li></ul></ul><ul><li>If anything goes wrong, boom no useable table! </li></ul>
    • 92. Utilities <ul><li>DB2 has import, export, load utilities </li></ul><ul><ul><li>Load is fastest way to get data into table </li></ul></ul><ul><ul><li>Load can handle various delimiters or no delimiters </li></ul></ul><ul><ul><li>You can replace or insert (append) </li></ul></ul><ul><ul><li>Terminate or restart </li></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><li>Load from /pathname/filename </li></ul></ul><ul><ul><li>Of del modified by coldel| keepblanks anyorder </li></ul></ul><ul><ul><li>Messages messagefile.msg </li></ul></ul><ul><ul><li>Temp files path /large_directory </li></ul></ul><ul><ul><li>Replace into bob.xyz; </li></ul></ul>
    • 93. Utilities <ul><li>Another load example (using cursor): </li></ul><ul><ul><li>Declare cursor mycursor </li></ul></ul><ul><ul><li>select … </li></ul></ul><ul><ul><li>load from mycursor of cursor </li></ul></ul><ul><ul><li>METHOD P (1,2,3,4,5…) </li></ul></ul><ul><ul><li>replace INTO bob.xyz NONRECOVERABLE; </li></ul></ul><ul><li>Approx 25% faster than using “insert into tablename select from..” </li></ul>
    • 94. Utilities <ul><li>Another load example (mapping cols): </li></ul><ul><ul><li>load from strip.txt OF ASC </li></ul></ul><ul><ul><li>METHOD L (1 7,9 43,45 54,56 90,92 126,128 145, </li></ul></ul><ul><ul><li>147 148,150 160,268 277,336 336) </li></ul></ul><ul><ul><li>messages messagefile.msg </li></ul></ul><ul><ul><li>tempfiles path $WORKDIR </li></ul></ul><ul><ul><li>replace INTO bob.xyz NONRECOVERABLE; </li></ul></ul><ul><li>Import is slow </li></ul>
    • 95. Utilities <ul><li>Export has several differences from dbexport </li></ul><ul><li>By default numbers have a + and leading zeros </li></ul><ul><li>Character data is enclosed by double quotes </li></ul><ul><li>Character data is padded to full length </li></ul><ul><li>Example: </li></ul><ul><ul><li>Export to filename.out </li></ul></ul><ul><ul><li>Of del modified by coldel| decplusblank </li></ul></ul><ul><ul><li>Select date_provided, rtrim(record_id) from tabname; </li></ul></ul><ul><li>Used sed to strip out quotes and leading zeros </li></ul><ul><li>New parameters nochardel and stripLzeros </li></ul>
    • 96. Utilities <ul><li>Getting the ddl </li></ul><ul><li>Informix: dbschema </li></ul><ul><li>Dbschema –d databasename outputfilename.out </li></ul><ul><li>DB2: db2look </li></ul><ul><li>Db2look –d databasename –e > outputfilename.out </li></ul><ul><li>Both have many options </li></ul><ul><li>Both have usage built in, just type command </li></ul>
    • 97. Error Messages <ul><li>Both databases provide error messages from the command line </li></ul><ul><ul><li>INFORMIX: finderr –217 </li></ul></ul><ul><li>-217 Column column-name not found in any table in the query </li></ul><ul><li>(or SLV is undefined). </li></ul><ul><li>The name appears in the select list or WHERE clause of this query but is… </li></ul><ul><ul><li>DB2: db2 ? SQL0203 </li></ul></ul><ul><li>SQL0203NA reference to column &quot;<name>&quot; is ambiguous. </li></ul><ul><li>Explanation: The column &quot;<name>&quot; is used in the statement … </li></ul>
    • 98. INFORMIX XPS (Version 8.x) <ul><li>DB2 does not have the external table feature, must up import, export and load utilities </li></ul><ul><li>DB2 requires explicit indexes to perform adequately </li></ul><ul><li>DB2 does not have the join update/batch update feature (a subselect must be used) </li></ul><ul><li>DB2 does not support truncate command </li></ul>
    • 99. Summary <ul><li>Yes, you too can migrate to DB2! </li></ul>

    ×