Question  optimizing cz userinfo block ?

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   optimizing cz userinfo block ?
fuzioneer
CZ Newbie
 Codezwiz Site Donator
Status: Offline
Joined: Oct 31, 2003
0.00 posts per day
Posts: 8
Points: 3,384
   
I have the CZUserinfo block with a few small tweaks to accommodate our subscription model on our site (It does a single query to find the database to get subscription status for each user)

Now I am no SQL Expert so not sure if our extra query line is the issue or whether it is the way the block operates but..

I just noticed our front page had almost 300 queries to produce, we had about 150 members online at the time, i temporarily disabled the cz user info block and the queries dropped down to 140 !!!

would the number of queries increase so high due to the number of members online (I note that the number of queries to produce the front page increases vs the number of members online at the time)



Back to top Reply with quote
#2   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,475
   
So for each user online it does a query for the status of thier subscription?

Then 150 people online equals an extra 150 queries.

Best bet is to write a JOIN statement for the subscription table and the online table so it runs as one query.

Post the query for the online users and the query your using to get the subscription.




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   
fuzioneer
CZ Newbie
 Codezwiz Site Donator
Status: Offline
Joined: Oct 31, 2003
0.00 posts per day
Posts: 8
Points: 3,384
   
thx for the offer of help

your query is as follows:-

SELECT w.uname, u.user_id, u.user_level, u.user_rank, u.user_allow_viewonline FROM ".$prefix."_session AS w LEFT JOIN ".$prefix."_users AS u ON u.username = w.uname WHERE guest = '0' ORDER by u.username ASC


my query is:-

$isnr = $db->sql_numrows($db->sql_query("SELECT * FROM ".$user_prefix."_premium_members_zone WHERE user_id='$session[user_id]'"));



Back to top Reply with quote
#4   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,475
   
Give this a shot...


SELECT w.uname, u.user_id, u.user_level, u.user_rank, u.user_allow_viewonline, p.user_id AS premium FROM ".$prefix."_session AS w LEFT JOIN ".$prefix."_users AS u ON (u.username = w.uname) LEFT JOIN ".$user_prefix."_premium_members_zone AS p ON (p.user_id = u.user_id) WHERE w.guest = '0' ORDER by u.username ASC


If they are premium then 'premium' will have the user_id variable.


if ($session['premium']) {
     //do something
}




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#5   
fuzioneer
CZ Newbie
 Codezwiz Site Donator
Status: Offline
Joined: Oct 31, 2003
0.00 posts per day
Posts: 8
Points: 3,384
   
perfect many thx dropped from 340 queries to 155 !!!



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum