Forum Moderators: phranque
// 0.0115
SELECT classifieds.id, username, price, classifieds.expiration, title, classifieds_img.image, description
FROM classifieds
JOIN classifieds_county
ON classifieds_county.id = classifieds.id
LEFT JOIN classifieds_img
ON classifieds_img.id = classifieds.id
WHERE
(
(
category= '%s'
AND subcat= '%s'
)
# Not the same as above, uses different values for %s
OR (category = '%s' AND subcat = '%s')
)
AND status = '%s'
AND classifieds.expiration >= %s
AND classifieds_county.county='%s'
AND COALESCE(classifieds_img.sorter,0) = 0
ORDER BY id DESC
// 0.0678
SELECT username, COUNT(1) AS nums
FROM classifieds
INNER JOIN classifieds_county
ON classifieds_county.id = classifieds.id
WHERE classifieds_county.county='%s' AND
status = '%s' AND
classifieds.expiration >= %s
GROUP BY username // 0.0329; not sure why this is slower than the first query with more WHERE
// statements, maybe just a server load fluke?
SELECT classifieds.id, username, category, subcat, price, classifieds.expiration, title, classifieds_img.image, description
FROM classifieds
JOIN classifieds_county
ON classifieds_county.id = classifieds.id
LEFT JOIN classifieds_img
ON classifieds_img.id = classifieds.id
WHERE status = '%s'
AND classifieds.expiration >= %s
AND classifieds_county.county='%s'
AND COALESCE(classifieds_img.sorter,0) = 0
ORDER BY id DESC while ($row = mysqli_fetch_row($sth)) {
list($id, $username, $price, $expiration, $title, $img, $desc = $row;
if ($count[$username]) $count[$username]++;
else $count[$username] = 1;
// showing %s to match the first query, but this would really be $_GET['whatever']
if ($category == '%s' && $subcat == '%s')
array_push($classifieds, $row);
}
while (list($id, $username, $price, $expiration, $title, $img, $desc) = $row) {
// format and echo
} $time_start = microtime ( true ) ;
/.../
$time_end = microtime ( true ) ;
$execution_time = ( $time_end - $time_start ) ; array_push($classifieds, $row); $classifieds [ ] = $row ;