Re: Speeding up SELECT statement
Jan Eden <[email protected]>
| Newsgroups | gmane.comp.db.mysql.perl |
|---|---|
| Message-ID | <r02010500-1038-5CFFD9B3A1C011D9A868000A959B4026@[10.149.23.127]> |
Hi,
Jan Eden wrote on 31.03.2005:
>Hi,
>
>my setup is the following: I request a number of records from the
>database and print them out in an unordered HTML list. For each item
>of a certain type (category), I want to display the number of its
>"children".
>
>This is what I currently do:
>
>my $query = sprintf("SELECT page_id, title, visible, user_id,
>position, page_type FROM pages WHERE mother_id = $id ORDER by
>position, title LIMIT %d,%d", $start-1,$per_page); my $sth =
>$dbh->prepare($query); $sth->execute();
>
>my $count_query = "SELECT page_id FROM pages WHERE mother_id = ?";
>my $count_handle = $dbh->prepare($count_query);
>
>while (my $page = $sth->fetchrow_hashref) {
>my ($rowcount) = $count_handle->execute($page->{page_id}) if
>$page->{page_type} == 0;
>[...]
>}
>
Correction: I used "rows" to get the row count - the version I sent was faulty. Sorry.
>I tried using SELECT COUNT(*) in the $count_query, but this did not
>help much.
Thanks,
Jan
--
How many Microsoft engineers does it take to screw in a lightbulb? None. They just redefine "dark" as the new standard.
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/[email protected]