Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
Anyone to tell if this is actually the fastest way to retrieve information from a data base, or if there is a better and fast way to do it?
Here is what I am using:
while ( $ac_num = $sth->fetchrow_arrayref()) { print "<br><font color=red><b>Print for testing only: @{$ac_num}</ +b></font><br>\n"; push (@all_num,@{$ac_num}); { print "<br><font color=red><b>For testing results: ^^^^^@all_num^^^^^ +</b></font><br>";
Thank you all!

Replies are listed 'Best First'.
Re: Question - fetchrow_arrayref
by erix (Prior) on Jan 07, 2005 at 20:39 UTC
Re: Question - fetchrow_arrayref
by jZed (Prior) on Jan 07, 2005 at 19:36 UTC
    This is the third thread this week that has asked that question. I don't usually reply with RTFM, but, in this case I'll make an exception. The DBI docs give an unambiguous answer to your question (in short, no it isn't the fastest way, but it's close enough to not matter unless you are retrieving a large number of rows and the actual makeup of your SQL is much more likely to impact performance). Please read those docs.
Re: Question - fetchrow_arrayref
by JSchmitz (Canon) on Jan 07, 2005 at 20:14 UTC
    You could give DBIx::FetchLoop a spin....
    use DBIx::FetchLoop; $lph = DBIx::FetchLoop->new($sth, $dbi_method); $hash_ref = $lph->fetch_current_data; $rowset = $hash_ref->{previous}; $rowset = $hash_ref->{current}; $rowset = $hash_ref->{next}; $rowset = $lph->fetch_current_row; $rowset = $lph->previous; $rowset = $lph->current; $rowset = $lph->next; $lph->set_aggregate($new_field, $field); $lph->reset_aggregate($new_field); $lph->set_concatenate($new_field, $field); $lph->reset_concatenate($new_field); $boolean = $lph->pre_loop($field); $boolean = $lph->post_loop($field); $boolean = $lph->pre_loop_substr($field,$offset,$length); $boolean = $lph->post_loop_substr($field,$offset,$length); $boolean = $lph->is_first; $boolean = $lph->is_last; $count = $lph->count;
Re: Question - fetchrow_arrayref
by TomDLux (Vicar) on Jan 10, 2005 at 18:35 UTC

    Printing HTML will never retrieve things from your database.

    I would suggest something along the lines of:

    select * from <tablename> where <condition>

    --
    TTTATCGGTCGTTATATAGATGTTTGCA