There is a major problem here. If you have 30 million items which take, say, 40 bytes of memory each (an empty string takes 28 before you put anything in it) you're talking 1.2 GB of RAM. If you have 2 million rows, you could find yourself going past the 2 GB addressing limit for 32-bit code. I would therefore strongly suggest
not putting it into RAM. Instead insert the data as you read with something like this:
# Assume that %file has the filename for each field in your
# table and @fields has the list of field names.
my @fhs;
for my $field (@fields) {
open(my $fh, "<", $file{$field})
or die "Can't open '$file{$field}: $!";
push @fhs, $fh;
}
while (1) {
my $did_read;
my @data;
for my $fh (@fhs) {
my $rec = <$fh>;
if (defined($rec)) {
$did_read++;
push @data, $rec;
}
else {
push @data, "";
}
}
if ($did_read) {
insert_data(@data);
}
else {
# Came to the end of all data streams
last;
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.