[ale] Organizing data
Jason Etheridge
phasefx at magusaptus.com
Tue Apr 27 22:40:06 EDT 2004
Chris Fowler wrote:
> Would this be the best way to group that data? I'm trying to do it in
> as few cycles as possible because I have no idea how big that report can
> get.
So you can't just pull the data out of the database whenever you want?
And when you do, you want to move this data into perl as quickly as
possible and worry about access speed later?
If using DBI, I'd be tempted to just dump the results into a file with
something like:
$rows = $sth->dump_results($maxlen, $lsep, $fsep, $fh);
But I don't know how efficient that is, and the man page doesn't
recommend it for data transfer applications. Hrmph.
fetchrow_arrayref is supposed to be the fastest access method, but you
can't keep the reference so I don't see what it buys over
fetchrow_array. If you want to store everything as delimited strings:
while ( @results = $sth->fetchrow_array ) {
$userid = pop @results;
$email = pop @results;
push @{ $user_data{$userid} }, join("|", at results);
if (! defined $user_email{$userid}) {
$user_email{$userid} = $email;
}
}
Probably faster just to keep pushing arrays rather than concatenate into
strings.
push @{ $users{$userid} }, @results;
But then retrieval is a little more complicated.
Is this the type of stuff you're looking for? I don't know perl's
object oriented stuff yet.
-- Jason
More information about the Ale
mailing list