PDA

View Full Version : 50 queries and counting, please help!


Xelation
07-17-2003, 03:42 AM
Ok, I'm working on localhost here and Im trying to reduce queries... Ive installed xenons forum home optimizing hack.. now ive come to the showthread and there are far to many queries and I must reduce them... can anyone hlep me out?

Lesanes awards hack is causing the most damage and was wondering if anyone can help me fix that without getting rid of the awards hack?

see next post for query report....

Xelation
07-17-2003, 03:42 AM
Fixed see new report below

Erwin
07-17-2003, 04:31 AM
Add these to your showthread.php

$templatesused="";

(you may have to add it to both showthread and postbit sections)

,unregged,vbcode_smiliebit,vbcode_smilies,showthre ad_replybox,yesterday,awards

That's 6 queries down.

To go down more, you will have to uninstall the Awards hack, which is creating a loop, and giving you 1 query per post per thread.

Xelation
07-17-2003, 04:36 AM
Today at 01:31 AM Erwin said this in Post #3 (https://vborg.vbsupport.ru/showthread.php?postid=418363#post418363)
Add these to your showthread.php

$templatesused="";

(you may have to add it to both showthread and postbit sections)

,unregged,vbcode_smiliebit,vbcode_smilies,showthre ad_replybox,yesterday,awards

That's 6 queries down.

To go down more, you will have to uninstall the Awards hack, which is creating a loop, and giving you 1 query per post per thread.

Thanks it worked, any other things that could help? is it possible to somehow alter the awards hack to not loop like that?

Xelation
07-17-2003, 04:39 AM
Fixed, Updated Post Below

Erwin
07-17-2003, 04:46 AM
Add "today" to templatesused too.

Sorry, you would have to recode the Awards hack so that it doesn't loop like that. I would use an alternative - just use custom profile fields for awards - they use up no queries, are easy to set up, and easy to modify and customize.

Xelation
07-17-2003, 04:48 AM
Today at 01:46 AM Erwin said this in Post #6 (https://vborg.vbsupport.ru/showthread.php?postid=418368#post418368)
Sorry, you would have to recode the Awards hack so that it doesn't loop like that. I would use an alternative - just use custom profile fields for awards - they use up no queries, are easy to set up, and easy to modify and customize.

What would I have to do for hte profile feild thing?

Erwin
07-17-2003, 04:54 AM
Make new custom profile fields, make them not editable by user, not viewable by member in profile.

Using your mouse, hover over the edit link, and remember the profield id of each of them.

Then, go to Admin CP, User, and to the user you want to give award to, and put in the image HTML:

<img src="http://www.yoursite.com/images/awards.gif">

in the custom profield field text input.

Then in postbit template, add $post[field26] anywhere you want the image to show up. For people without awards it won't show up. In getinfo template, add $userinfo[field26] instead. Change 26 to the profile id you are using.

See? No hacking needed. :) Best of all, no additional queries at all.

Xelation
07-17-2003, 04:56 AM
Thanks! will do that

Xelation
07-17-2003, 05:03 AM
Ok now that I did that Im down to 23 queries which is perfect for me but one last time... is there anything else that could be brought down?


Query: SELECT template FROM template WHERE title='options'
Time before: 0.032304048538208
Time after: 0.033077955245972

--------------------------------------------------------------------------------

Query: SELECT sessionhash,userid,host,useragent,styleid FROM session WHERE lastactivity>1058421019 AND sessionhash='8840ab49cd89e1b94c671f9b9c48af33' AND (host='127.0.0.1' OR (althash='' AND althash<>'')) AND useragent='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;'
Time before: 0.039862990379333
Time after: 0.040616989135742

--------------------------------------------------------------------------------

Query: SELECT user.*,userfield.* FROM user LEFT JOIN userfield ON userfield.userid=user.userid WHERE user.userid='1'
Time before: 0.040820002555847
Time after: 0.041581034660339

--------------------------------------------------------------------------------

Query: SELECT * FROM thread WHERE threadid=5
Time before: 0.042281985282898
Time after: 0.042878985404968

--------------------------------------------------------------------------------

Query: SELECT forum.forumid,styleid,styleoverride FROM forum,thread WHERE forum.forumid=thread.forumid AND threadid='5'
Time before: 0.043076038360596
Time after: 0.043728947639465

--------------------------------------------------------------------------------

Query: SELECT templatesetid,replacementsetid,userselect FROM style WHERE styleid='1'
Time before: 0.043871998786926
Time after: 0.044232964515686

--------------------------------------------------------------------------------

Query: SELECT template FROM template WHERE title='unregged' AND (templatesetid=-1 OR templatesetid=1) ORDER BY templatesetid DESC LIMIT 1
Time before: 0.044376015663147
Time after: 0.044971942901611

--------------------------------------------------------------------------------

Query: SELECT template,title
FROM template
WHERE (title IN ('showthread_searchthread','showthread_ratingdispl ay','postbit_search','postbit_buddy','postbit_igno re','postbit_useremail','icq','aim','yahoo','postb it_homepage','postbit_profile','postbit_ip_show',' postbit_ip_hidden','postbit','postbit_sendpm','pos tbit_avatar','postbit_offline','postbit_online','p ostbit_editedby','postbit_signature','postbit_atta chment','postbit_attachmentimage','showthread_admi noptions','showthread_threadrate','showthread_poll results_voted','showthread_pollresults_closed','sh owthread_pollresults_cantvote','showthread_firstun read','showthread_nextnewestthread','showthread_ne xtoldestthread','forumrules','showthread','unregge d','vbcode_smiliebit','vbcode_smilies','showthread _replybox','yesterday','today','gobutton','timezon e','username_loggedout','username_loggedin','phpin clude','headinclude','header','footer','forumjumpb it','forumjump','nav_linkoff','nav_linkon','navbar ','nav_joiner','pagenav','pagenav_curpage','pagena v_firstlink','pagenav_lastlink','pagenav_nextlink' ,'pagenav_pagelink','pagenav_prevlink')
AND (templatesetid=-1 OR templatesetid=1))


ORDER BY templatesetid
Time before: 0.045385956764221
Time after: 0.054196000099182

--------------------------------------------------------------------------------

Query: SELECT * FROM usergroup WHERE usergroupid=6
Time before: 0.057448029518127
Time after: 0.058225989341736

--------------------------------------------------------------------------------

Query: SELECT * FROM forum WHERE forumid='2'
Time before: 0.05901300907135
Time after: 0.059674024581909

--------------------------------------------------------------------------------

Query: SELECT *,INSTR(',2,1,-1,', CONCAT(',', forumid, ',') ) AS ordercontrol FROM forumpermission WHERE usergroupid=6 AND (forumid='2' OR forumid='1' OR forumid='-1') ORDER BY ordercontrol LIMIT 1
Time before: 0.059928059577942
Time after: 0.060505986213684

--------------------------------------------------------------------------------

Query: SELECT title, smilietext, smiliepath FROM smilie
Time before: 0.060677051544189
Time after: 0.061126947402954

--------------------------------------------------------------------------------


Warning: Cannot add header information - headers already sent by (output started at c:\phpdev\www\public\forum\global.php:155) in c:\phpdev\www\public\forum\admin\functions.php on line 1723
Query: SELECT * FROM forum WHERE forumid='1'
Time before: 0.067188024520874
Time after: 0.067926049232483

--------------------------------------------------------------------------------

Query: SELECT forumid,parentid,displayorder,title FROM forum WHERE displayorder<>0 AND active=1 ORDER BY parentid,displayorder,forumid
Time before: 0.068737983703613
Time after: 0.069466948509216

--------------------------------------------------------------------------------

Query: SELECT forumid,canview FROM forumpermission WHERE usergroupid='6'
Time before: 0.069800972938538
Time after: 0.070139050483704

--------------------------------------------------------------------------------

Query: SELECT COUNT(*) AS posts FROM post WHERE post.threadid='5' AND post.visible=1
Time before: 0.0713210105896
Time after: 0.07197105884552

--------------------------------------------------------------------------------

Query:
SELECT post.postid FROM post
WHERE post.threadid='5' AND post.visible=1
ORDER BY dateline LIMIT 0,40

Time before: 0.072126984596252
Time after: 0.072932004928589

--------------------------------------------------------------------------------

Query:
SELECT
post.*,post.username AS postusername,post.ipaddress AS ip,user.*,userfield.*,icon.title as icontitle,icon.iconpath,
attachment.attachmentid,attachment.filename,attach ment.visible AS attachmentvisible,attachment.counter
,avatar.avatarpath,NOT ISNULL(customavatar.avatardata) AS hascustomavatar,customavatar.dateline AS avatardateline
FROM post
LEFT JOIN icon ON icon.iconid=post.iconid
LEFT JOIN user ON user.userid=post.userid
LEFT JOIN userfield ON userfield.userid=user.userid
LEFT JOIN avatar ON avatar.avatarid=user.avatarid
LEFT JOIN customavatar ON customavatar.userid=user.userid
LEFT JOIN attachment ON attachment.attachmentid=post.attachmentid
WHERE post.postid IN (0,6,7,8,9,10,11,12,14,15,17,18,19,20,21,22,23,24, 25,26,27,28,29,30,31)
ORDER BY dateline

Time before: 0.073382019996643
Time after: 0.083976984024048

--------------------------------------------------------------------------------

Query: SELECT smilietext,smiliepath FROM smilie
Time before: 0.086119055747986
Time after: 0.086783051490784

--------------------------------------------------------------------------------

Query: SELECT bbcodetag,bbcodereplacement,twoparams FROM bbcode
Time before: 0.10428297519684
Time after: 0.1049929857254

--------------------------------------------------------------------------------

Query: SELECT usergroupid FROM user WHERE userid=1
Time before: 0.20861601829529
Time after: 0.20922195911407

--------------------------------------------------------------------------------

Query:
SELECT findword, replaceword, replacementsetid
FROM replacement
WHERE replacementsetid IN(-1, '1')
ORDER BY replacementsetid, replacementid DESC

Time before: 0.22727394104004
Time after: 0.22868096828461

--------------------------------------------------------------------------------


Page generated in 0.21704995632172 seconds with 22 queries,
spending 0.03301465511322 doing MySQL queries and 0.1840353012085 doing PHP things.
Query: UPDATE session SET lastactivity=1058421919,location='/public/forum/showthread.php?s=&threadid=5&showqueries=1' WHERE sessionhash='8840ab49cd89e1b94c671f9b9c48af33' Time before: 0.26303398609161 Time after: 0.26349699497223
--------------------------------------------------------------------------------
Query: UPDATE user SET lastactivity=1058421919,inforum='2' WHERE userid='1' Time before: 0.26358199119568 Time after: 0.26394701004028
--------------------------------------------------------------------------------
Query: UPDATE LOW_PRIORITY thread SET views=views+1 WHERE threadid='5' Time before: 0.26403105258942 Time after: 0.26466202735901
--------------------------------------------------------------------------------



Thanks! :)

Dean C
07-17-2003, 10:31 AM
I run Lesane's awards hack and I have only 21 queries on my showthread :p

- miSt

Alien
09-04-2003, 07:42 AM
07-17-03 at 01:54 AM Erwin said this in Post #8 (https://vborg.vbsupport.ru/showthread.php?postid=418370#post418370)
See? No hacking needed. :) Best of all, no additional queries at all.

I seem to get a query per award field in the postbit?

lasto
09-04-2003, 07:48 AM
Page generated in 0.26946199 seconds (75.66% PHP - 24.34% MySQL) with 36 queries.
[Debug Mode OFF] [PHP v4.3.3] [GZIP disabled] [Output: 189.92 Kb. compressed to 142.72 Kb. by saving 47.20 Kb. (24.85%)] [Server Load: 0.52 ยป 0.31 : 0.32

36 queries and only 11 posts in this thread so hows that.No hacks installed like the awards hack etc so can someone explain.
I notice for every post made in a thread it adds between 2-3 queries and theres nothing that can be done about that.

@erwin i was gonna install awards hack today but now im gonna try your idea that u listed above.

lasto
09-04-2003, 08:23 AM
erwin got same effect and no extra queries - Cheers for that tip
All it means is no link in postbit to add em but when it comes to queries anything that gets rid of em is a god send.

Dean C
09-04-2003, 02:00 PM
Just add the data into an array and loop through the array :) - it works like a charm and you then have the nice admin cp options :)