Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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!

In reply to Re: faster with threads? by paulbort
in thread faster with threads? by js1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-03-28 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found