This script is poorly written, query wise.. Can U help??

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

bumblebore
New php-forum User
New php-forum User
Posts: 2
Joined: Fri Jan 31, 2003 12:29 pm

This script is poorly written, query wise.. Can U help??

Postby bumblebore » Fri Jan 31, 2003 12:39 pm

I am running a story database script, which although fine, runs slowly. I have been contacted by my host saying "the script is poorly written, query wise (which why it is slow) and is placing a burden on their server". The author is no longer online. A snippet of the code is below, and I have put up a link for the complete script if anybody feels they can help out with this.. Oh BTW my host is threatening to remove the script, because of the load on the server.


The script is here..
http://www.iodesigns.co.uk/scripts/download/slv18.zip

A sample...

<table border='0' width='100%' cellspacing='4'>
<tr>
<td class='cleardis'>

<?
$cl = new TheCleaner();

$dl = new TheDB();
$dl->connect() or die($dl->getError());
$dl->debug=false;

$table = $dl->select(
"s.*, u.*, a.*,cg.*,sg.*, COUNT(DISTINCT c.cid) AS chap, COUNT(DISTINCT r.rid) AS rev",
"sl18_stories s
LEFT JOIN sl18_chapters c ON c.csid=s.sid
LEFT JOIN sl18_users u ON u.uid=s.suid
LEFT JOIN sl18_rate a ON a.ratsid=s.sid
LEFT JOIN sl18_category cg ON cg.caid=s.scid
LEFT JOIN sl18_subcategory sg ON sg.subid=s.ssubid
LEFT JOIN sl18_review r ON r.rsid=s.sid",

"",
"GROUP BY s.sid ORDER BY s.stime DESC LIMIT 0,15"
);

if ( count( $table ) < 1 )
print "There are currently no published stories";
else {

foreach($table as $row) {

?>
<a href='story.php?no=<?=$row["sid"]?>'><?=$cl->preva($row["sname"])?></a><br>
<?=$cl->preva($row["sdescrip"])?><br>
<font class='small'>
<?=$cl->preva($row["caname"])?> > <?=$cl->preva($row["subname"])?> -:-
<a href='authors.php?no=<?=$row["uid"]?>'><?=$cl->preva($row["upenname"])?></a> -:-
<?=rating($row[srating])?> -:-
Chapters [<?=$row["chap"]?>] -:-
Published [<?=$row["sdate"]?>] -:-
Updated [<?=$row["scdate"]?>] -:-
Reviews [<a href='review.php?set=read&no=<?=$row["sid"]?>'><?=$row["rev"]?></a>] -:-
Average Vote [<? showrate(@ceil($row["rattotvote"] / $row["ratnovote"])) ?>]
</font>
<p>

<?
}
}
?>

</td>
</tr>
</table>

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Fri Jan 31, 2003 1:38 pm

One reson I see there is a problem is because of all the LEFT JOINS in the query which is very resource intensive.

bumblebore
New php-forum User
New php-forum User
Posts: 2
Joined: Fri Jan 31, 2003 12:29 pm

Postby bumblebore » Fri Jan 31, 2003 2:25 pm

As I`m still learning about this PHP stuff, what is the answer..Remove them, recode it..

Thanks for taking the time to answer


Return to “PHP coding => General”

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 3 guests