Speeding up MySQL query??
Posted: Mon Jun 16, 2003 7:12 pm
I have a stats / traffic program I have been working on off and on for a little while. I am trying to speed up the results pages because it is talking a long time to produce the query.
Bassically I have 2 tables. 1) visitor information and 2) page view information. Note this has been scaled down to help make since
first query:
for each result I query again:
I have over 100,000 rows in the statspv table and it taked a long time to load this wey. Is there a better / faster way to do this?
Thanks for any input.
Tim
Bassically I have 2 tables. 1) visitor information and 2) page view information. Note this has been scaled down to help make since
first query:
Code: Select all
<?php
$result = @mysql_query("SELECT stats_id, etc, etc FROM stats ORDER BY st_id DESC LIMIT 20" );
?>Code: Select all
<?php
$result2 = @mysql_query("SELECT pv_id, COUNT(*) AS tpv FROM statspv WHERE pv_ref_id='$stats_id' GROUP BY pv_ref_id" );
$row = mysql_fetch_array($result2);
$tpv = $row["tpv"];
?>Thanks for any input.
Tim