in reply to Need faster MySql data fetching with perl DBI

Are you absolutely sure that it's the same SQL statement that produces such great differences between DBI and the command-line client? Not that a Perl-caused slowdown is out of the question, but that's always the first thing I'd double-check.

If you're getting back a ton of data from each query, then a slowdown in Perl is quite likely, especially if you're using fetchrow_array. Take a look at Speeding up the DBI, which has recipes for faster ways to fetch lots of data. However, it sounds like the slowdown happens even when no data is returned. In that case, you should do some careful DBI profiling. Most likely most of the time is spent waiting for the MySQL server's slow response..

blokhead

  • Comment on Re: Need faster MySql data fetching with perl DBI

Replies are listed 'Best First'.
Re^2: Need faster MySql data fetching with perl DBI
by shaolindoman (Acolyte) on Jul 16, 2004 at 02:07 UTC
    Ok, well I took one statement DIRECTLY out of my code and tried it on the command line. Sure enoug, 6.98 seconds. That seems to be the slow down now I assume. I guess I'm going to have to figure out more efficient ways to fetch the data. I will take a look at the links you posted to see if they provide any help. Thanks!
      Did you use indexes?
        Well I have narrowed it down to the SQL statements themselves. In the first script I call I tested my 2 SQL calls and they took a total of 21 seconds. No, I'm not familiar with indexes. I've started reading the O'reilly book Managing and Using MySql and I've seen it mentioned but I havn't taken the dive to learn about them yet. I have plenty of space to use (since I heard this is what they require). My database only takes up about 70 MB (down oddly enough from 175 MB since I switched from MS Access). Any suggestions for a quick start before I dive back into my book and the MySql Docs?