Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: faster with threads?

by paulbort (Hermit)
on Jun 09, 2004 at 13:18 UTC ( #362721=note: print w/replies, xml ) Need Help??

in reply to faster with threads?

If you want this to go faster, I would suggest not worrying about threading, and worry about the inserts instead. Inserts are slow operations on almost any (every?) database.

I don't know MySQL at all, but every other database I've run into has a "bulk insert" mode or command. If you want this to go fast, do whatever you have to in Perl to get the data into a format that can be bulk inserted. (In PostgreSQL, this would be a simple line transform, since the bulk insert format is plain text and "COPY FROM STDIN" magic.) If MySQL doesn't have a bulk insert method, you might want to reconsider your database choice.

The other thing that will help is to do the bulk insert to a table that has no indexes, then move the data to an indexed table (using SQL) when the machine has spare time. This could be done with Perl and DBI, or maybe an ON DELETE trigger that then inserts the record in the indexed table.

Once you're doing bulk inserts, if you are still having performance concerns, then some sort of buffering is appropriate. (both the pipe and queue suggestions above are valid, pick the one you feel most comfortable with.)

Spring: Forces, Coiled Again!

Replies are listed 'Best First'.
Re^2: faster with threads?
by bsb (Priest) on Jun 10, 2004 at 03:50 UTC
    There is a bulk insert for mysql (LOAD DATA INFILE) and I completely agree with you on the speed issue. Threading seems to buy nothing but pain in this case.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://362721]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2019-07-17 21:24 GMT
Find Nodes?
    Voting Booth?

    No recent polls found