Question

MySQL must be configured wrong, but I can't see where

Asked by: KurtVon

Okay, this is likely an obvious screw up on my part.  Everything is running fine except for one issue: MySQL is taking over ten times as long to do a query as MS Access.  I refuse to believe this is a valid benchmark.

The Windows and Linux versions are using the exact same code though JDBC, but I phpMySql gives the same time for a query, so I don't think it's JDBC overhead.  Both are running on Sun Java 1.6 but it's possible the Windows and Linux clients could be different.

The query itself returns 9,000 recordsets, and both databases are indexed on every column (this is for benchmarking a system, I'll eliminate unneeded ones later).

So the real possible places are how the services  are running, the connection, or the hardware.

So here's how it breaks down:

  Windows: Access running as part of office, connection string is "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=c:/test.mdb;DriverID=22;READONLY=true}", on a 2.4 Ghz Core 2 Quad, 3GB ram.

  Ubuntu server: MySQL default install (apt-get), connection string is "jdbc:mysql://localhost/test", on a 2 GHz Core 2 Duo, 4GB RAM.

Even if multiprocessing is used to its fullest I don't see how it would give more than a 3 times speed increase, and there is no way it's that efficient.  Top shows nothing of any significance is running in the background on the Linux machine, while the Windows machine is running, well, everything.

The annoying part is that the whole comparison scales smoothly, queries that take 200ms on MySQL are taking 30ms on Access, and queries that take 1500ms on MySQL are taking 140ms on Access.

So it has to be a configuration issue of some sort.  Or maybe the quad core really is that much more efficient?

I'd appreciate any hints as to what I screwed up, because I know I did something wrong.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-08-25 at 08:47:57ID23675575
Tags

MySQL

,

14.12

,

Linux

Topic

MySQL Server

Participating Experts
1
Points
250
Comments
12

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ODBC - mysql - FOXPRO
    Can somebody give me sample code for connecting, quering, inserting, updating to MYSQL and FOXPRO databases thru ODBC.
  2. mySQL with out odbc??
    hello, if i create a program that uses an odbc connection to connect to a mysql db server, is there a way to make the program dependent? I mean can i somehow create a program that allows me to connect to my server with out an mysql db odbc? can you show some code? thanks!
  3. Recordset not updating for MySQL
    How do i make this so it will add/update records for MySQL, also i dont know if i did something or what but the i use to be able to get a list of sub commands from the recordset Ex. krs2.Fields or krs2.update now i have to type manual how can i get this to pop back up and wor...
  4. ODBC connection to MySQL
    Hi I am writing an application in c# that needs to connect to a MySQL database. I don't have the option to install anything on the web server (it is a hosted site) and so I have to use a DSN-Less connection. I have tried 2 different connection strings but with no luck, the...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: KurtVonPosted on 2008-08-25 at 12:17:53ID: 22308249

For what its worth, installed on the Windows dev machine MySQL was almost twice as fast as Access, so it is definitely not MySQL.

I didn't make any changes to the default Ubuntu install, though, so I'm at a loss as to what the issue is.

 

by: fiboPosted on 2008-08-28 at 15:31:07ID: 22340548

Some guesses:

1 - I see in your Access string "readonly". Would that have an impact?

2 - What is the RAM space allocated to MySQL on this machine?
More generally, any idea coming from
http://dev.mysql.com/doc/refman/4.1/en/server-parameters.html
http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html ?

3 - Are your mysql tables ISAM or Innodb?

4 - with phpmyadmin or other, can you run an OPTIMIZE on the tables?

5 - Ask for an EXPLAIN of your test-query. Anything special?

6 - Are you comparing (Access results on the same machine than the Access base) with (MYSQL results collected on the same machine than MySQL) or are you comparing to (MYSQL results collected on a remote client thru a network link to MYSQL server)? In that last case, what is the volume of data transferred?

 

by: KurtVonPosted on 2008-08-28 at 17:41:53ID: 22341218

1.  I don't know why Access requires that as the ReadOnly flag seems to have no effect I can discern.

2. It was the default innodb_buffer_pool_size of 8MB, but expanding it to 1GB didn't have any impact (I noticed the linked connection was also just 8MB).

3. InnoDB.  I tried ISAM but it actually was even slower for the query I am running.

4. I didn't know myPhpAdmin could do that, I'll take a look.

5. Explain suggested an index which did help a bit, and I'm not clear why Access worked with just the obvious ones.

6. No, not the same machine.  The windows one is about three times faster taking multithreading into account and assuming 100% efficiency.  I doubt it is more than 2.5x faster in reality, which still leaves a 4x discrepancy (well, a 3x discrepancy with the larger buffer size and suggested index).

On suggestion of a website I found while researching this I tried installing a 64-bit version of Linux and that gave a boost to the point where the speeds are about the same taking into account the differences on the computers.  But it still doesn't feel right that the version of Access that comes with Office, running under 32-bit XP and completely un-tuned, should match a tuned version of MySQL under 64-bit Linux.

I'm not dissing MySQL, I'm just concerned I'm not doing something right because it goes against all common sense.  Access is not Microsoft's flagship product.

 

by: fiboPosted on 2008-08-28 at 22:56:08ID: 22342821

<<5. Explain suggested an index which did help a bit, and I'm not clear why Access worked with just the obvious ones.>>

Maybe there is something here: when running a query, MySQL uses just ONE index to define its optimization strategy, while Access's data engine might use several

Another desparate attempt: in MySQL are you using SELECT * or with just the same list of fields as in Access? Have you compared your MySQL SQL query with the text of Access SQL query? There would be some slight differences, but not that much.
Would you mind pasting both texts here?

 

by: KurtVonPosted on 2008-08-29 at 06:53:31ID: 22345361

A graph of the run times showed a discontinuity at 60,000 recordsets in MySQL (59,935 to be exact), so it may be a memory issue after all.  Sorry I didn't see it earlier, but it isn't obvious at all until you graph it (a jump of 6 seconds to 9 seconds) since the growth on either side of the discontinuity is identical.  64-bit OS smooths that out, which is why the performance gain is bigger on larger sets.

A little background before presenting the query.  What we have is a journal of row/column/vale sets.  Each cell has a history, and the query gets the latest values (or as of a certain date/time).  The Access and MySQL queries are identical (or rather, the changes I made to get MySQL working backport fine).

The query is in the code section below.

Unfortunately the final query needs to select that into a temp table and filter out based on (column, value) pairs, but that is the core of the issue right now.

SELECT journal.rowid, journal.column, journal.value AS last_value 
   FROM `journal` INNER JOIN 
      ( SELECT `rowid`, `column`, MAX(`date`) FROM `journal` WHERE `name` = ? GROUP BY `rowid`, `column` ) AS T
   ON journal.rowid = T.rowid AND journal.column = T.column AND journal.date = T.date
   WHERE journal.op <> 'd'
   ORDER BY journal.rowid;
                                              
1:
2:
3:
4:
5:
6:

Select allOpen in new window

 

by: fiboPosted on 2008-08-29 at 17:43:05ID: 22350060

1 - Note that when going from 32 bits to 64 bits it seems that your memory total size increases: here at EE some have reported a doubled memory need, as if the need was in "words" of 32 (or 64) instead of bytes.
If your app performance is highly important, you might want to make comparison with 32 bits

2 - Consider adding to journal a composite index, not unique, made from (rowid, column) in that order.
What does EXPLAIN say?

 

by: KurtVonPosted on 2008-08-29 at 18:49:50ID: 22350228

1. The 32 bit Linux was the initial analysis.  Switching to 64 bits was a 3x gain in speed.  I still haven't come close to using available RAM, so that shouldn't be an issue.

2, Explain suggested (rowid, column, date) which did cause a significant improvement.  As I said, with the proper index and 64 bits MySQL is now neck-in-neck with Access on XP.

I've been watching the performance tuning seminars on the MySQL website and they suggest using small queries with temporary tables over large queries.  I don't know if the query counts as large, but when I tried splitting it up it neither improved nor hurt performance until I did an inner join on two temporary tables.  It seems the query is very fast for everything up to that point (much faster than the complete query) but then a simple

SELECT temp1.rowid, `column`, `value` FROM temp1 INNER JOIN temp2 ON temp1.rowid = temp2.rowid;

takes 5 seconds, 70% of the total time.

Could that be  the core of the issue?

 

by: fiboPosted on 2008-08-30 at 01:02:35ID: 22351037

This query is probaly quite long if none of the temp files are indexed.
What are usually typical respective sizes for temps1 and temp2? If they are usually quite different, you might experiment the effect in the ON clause to put the smaller first, ie ON temp2.rowid=temp1.rowid  if temp2 has lots less records than temp1

Your query is currently running as a stored procedure. What is the performance impact of running the query as a normal query?

 

by: KurtVonPosted on 2008-09-02 at 05:43:02ID: 22366667

Well, temp2 is guaranteed to be smaller than temp1 because it is a subset.  It only exists because I can't use the same temporary table twice in a select statement.

I haven't tried it as a stored procedure.  Will that actually make much of a difference on a straightforward query like this?

Thanks for all this help, but since so far I've just been getting small improvements (except for converting to 64 bits) I suspect I'm not misconfigured and it's just something about the nature of the schema I am using.

 

by: fiboPosted on 2008-09-03 at 00:21:15ID: 22374734

<<Well, temp2 is guaranteed to be smaller than temp1 because it is a subset.  It only exists because I can't use the same temporary table twice in a select statement.>>
You then might want to extract values from temp2 rather than temp1

<<I haven't tried it as a stored procedure.  Will that actually make much of a difference on a straightforward query like this?>>
I would have thought that your initial query is a stored procedure. So I was suggesting to test the impat of running it directly, ie with a value to match 'name'

<<since so far I've just been getting small improvements (except for converting to 64 bits) I suspect I'm not misconfigured and it's just something about the nature of the schema I am using.>>
That is probable. The fact that MySQL optimizes queries around one single index is probably the main factor here.
This means that although Access handles it "naturally" you have to tune it for MySQL, ie working on:
- the logic of the queries
- the indexes to use

 

by: KurtVonPosted on 2008-09-03 at 17:48:27ID: 22383401

I tried a stored procedure, but the time was unchanged.  I then tried moving some of the filtering into the Java caller and was pleasantly surprised.  It seems that filtering on some parts improves the speed in SQL, but a simple trade-off with Java allowed other things to filter faster there.

I'd call the speed I have now adequate.  It isn't great, but it's something I can justify to my boss.

Thanks.

 

by: fiboPosted on 2008-09-03 at 22:55:36ID: 22384550

B-)) Glad it is now manageable. Thx for the grade and the points

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...