Chris Tankersley

  • Home
  • About
  • Portfolio
  • Projects
Twitter RSS
Monthly Archives: December 2010

PHP 5.2 and MySQL 5 vs SQLQUERY and IBM DBU on V5R4

Posted on December 19, 2010 by Chris
No Comments

This is completely not at all scientific, but at work we needed to do what amounted to a giant SQL query to generate a stats file. The query itself was against two tables – one was 200,000 rows long and the other was 4.6 million rows long. We needed to add up many of the columns to get a row-by-row analysis on the individual pieces of a product, per customer.

The iSeries is a single CPU Power5 CPU running at 2.7ghz (I think), with 8gb of RAM and about 100gb of free harddrive space. We first ran the query on the iSeries using SQL. Within about 20 minutes we had eaten up 50gigs worth of hard drive space on the black box and had capitalized the CPU. That posed a problem as that meant we had used about 95% of the available harddrive space on the box, and the iSeries tends to shut down when that happens. The query was eventually killed.

Since the analysis was just a giant SQL query, I suggested moving it to one of the MySQL servers. It was an Ubuntu 8.04 box with half a gig of ram, 34gig of free hard drive, and a dual-core Xeon at 2.5ghz, all inside VMWare ESXi that is also running about 7 other VMs. Its actually one of our smaller virtual servers, but I figured we could sacrifice raw power for time.

We copied the tables to CSV, created the tables on the MySQL server, and then ran a PHP script to import the CSV files. All-in-all it took about 6 hours between beginning and end as giant 7gig files were shunted around the network and imported. I took the original query and modified it a bit for the joins, added an outfile to save the results, and set it to run.

I watched it for a bit. The CPU on the box never went about 75% on the query, though we had hit 100% during the import of the 4.6 million row database, and memory usage was never really above 20%. For the size of the tables, I was actually surprised. I let it just run.

In total, the first run took about 3.5 hours to run. I then learned that outfiles need an absolute path, not relative. Oh well. I ran it again and this time it ran in 2 hours, 48 minutes, which included actually generating the file. The file itself was almost 3gigs and 10 million lines long.

Not too shabby I’d say. The younger DB server on a small virtual machine did much better on resources than the more mature OS and hardware.

Categories: IBM i, MySQL, PHP | Tags: Coding, ibm, Linux, MySQL, Performance, PHP
  • Search

  • Archives

    • February 2012
    • January 2012
    • September 2011
    • August 2011
    • April 2011
    • December 2010
    • November 2010
    • September 2010
    • August 2010
    • May 2010
    • April 2010
    • February 2010
    • January 2010
    • November 2009
    • October 2009
    • September 2009
    • June 2009
    • May 2009
    • February 2009
    • January 2009
    • November 2008
    • October 2008
    • July 2008
    • May 2008
    • February 2008
    • December 2007
    • October 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
  • Categories

    • Code Releases
    • Doing Development
    • Hardware
    • IBM i
    • JavaScript
    • Joomla!
    • MySQL
    • Non-Programming
    • Operating Systems
    • Personal
    • PHP
    • Programming
    • Project Management
    • Reviews
    • Servers
    • Software
    • This Site
    • Tutorials
    • TWS Software
    • Uncategorized
    • ZendCon 2010
© Chris Tankersley. Proudly Powered by WordPress | Nest Theme by YChong