MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 28th, 2000, 09:37 PM
AlexDG AlexDG is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 1999
Location: Canada, Toronto
Posts: 103 AlexDG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to AlexDG
Hi there!

I'm building here a site in PHP3 with MySQL. I was just wondering, how many queries is too many? My first page now does 21 each time it's loaded.

Of course, I understand it all depends on complicity of queries and other factors, but still, is there a general rule for this?

Thank you in advance!


------------------
Alex D. G.
http://www.alexdg.com


Reply With Quote
  #2  
Old March 29th, 2000, 06:04 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
As few as possible

There's no way to judge how many is optimal as too many factors weigh in. However, 21 does seem very excessive. Are you sure there isn't someway to optimize those with table joins?

Reply With Quote
  #3  
Old March 29th, 2000, 09:10 AM
AlexDG AlexDG is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 1999
Location: Canada, Toronto
Posts: 103 AlexDG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to AlexDG
I dont have table joins... it's mostly regular SELECT with minimal WHERE options and no GROUP at all... a couple of INSERTs and that's it...

6 UPDATE
6 INSERT
9 SELECT

but i'm afraid i'll have to put more... i haven't implemented page counter yet...

i think INSERTs are very fast since no search is required... as for the rest, i donno =(


------------------
Alex D. G.
http://www.alexdg.com


Reply With Quote
  #4  
Old March 29th, 2000, 10:07 AM
timbo timbo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 1999
Location: London
Posts: 110 timbo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 26 sec
Reputation Power: 0
i had a look at your page and could only work out three possible select stmts, are you doing select stmts for each of the little images that change ?

give us a clue as to what all the stmts are about and I'll have a look if you want

t

------------------
cheers

Reply With Quote
  #5  
Old March 29th, 2000, 10:18 AM
AlexDG AlexDG is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 1999
Location: Canada, Toronto
Posts: 103 AlexDG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to AlexDG
Neah... my page is a very earlier prototype of the system i'm working on now...

here is the list of all mysql queries:

--- retrieving all possible 468x60 banners
SELECT * FROM ads_banners WHERE size='468x60' AND (impressions <= impressions_purchased OR impressions_purchased = 0) AND (clicks <= clicks_purchased OR clicks_purchased = 0) AND status='on' AND UNIX_TIMESTAMP(start) < '954345166' AND (UNIX_TIMESTAMP(end) >= '954345166' OR UNIX_TIMESTAMP(end) = '0')

--- after chosing one randomly updating it's impressions number
UPDATE ads_banners SET impressions=impressions+1 WHERE id='12'

--- inserting banner id and host IP for clients statistic
INSERT INTO ads_impressions (bannerid, host) VALUES ('12', '192.168.1.102')

--- doing the same for a smaller banner 234x60
SELECT * FROM ads_banners WHERE size='234x60' AND (impressions <= impressions_purchased OR impressions_purchased = 0) AND (clicks <= clicks_purchased OR clicks_purchased = 0) AND status='on' AND UNIX_TIMESTAMP(start) < '954345166' AND (UNIX_TIMESTAMP(end) >= '954345166' OR UNIX_TIMESTAMP(end) = '0')
UPDATE ads_banners SET impressions=impressions+1 WHERE id='18'
INSERT INTO ads_impressions (bannerid, host) VALUES ('18', '192.168.1.102')

--- retrieving FOUR small buttons 88x31, updating impressions
SELECT * FROM ads_banners WHERE size='88x31' AND (impressions <= impressions_purchased OR impressions_purchased = 0) AND (clicks <= clicks_purchased OR clicks_purchased = 0) AND status='on' AND UNIX_TIMESTAMP(start) < '954345166' AND (UNIX_TIMESTAMP(end) >= '954345166' OR UNIX_TIMESTAMP(end) = '0')
UPDATE ads_banners SET impressions=impressions+1 WHERE id='7'
INSERT INTO ads_impressions (bannerid, host) VALUES ('7', '192.168.1.102')
UPDATE ads_banners SET impressions=impressions+1 WHERE id='5'
INSERT INTO ads_impressions (bannerid, host) VALUES ('5', '192.168.1.102')
UPDATE ads_banners SET impressions=impressions+1 WHERE id='9'
INSERT INTO ads_impressions (bannerid, host) VALUES ('9', '192.168.1.102')
UPDATE ads_banners SET impressions=impressions+1 WHERE id='4'
INSERT INTO ads_impressions (bannerid, host) VALUES ('4', '192.168.1.102')


--- following two queries pick one random message from one group of messages. First query makes sure that the group you are trying to get a message from is visible
SELECT * FROM rnd_groups WHERE title='did you know'
--- second is retrieving the actuall message
SELECT * FROM rnd_random WHERE isshow='Y' AND groupid='2'

--- getting four most recent tutorials
SELECT * FROM tutorials ORDER BY time DESC LIMIT 0,4

--- getting 10 most recent headlines
SELECT *, DATE_FORMAT(time, 'M d h:i p') AS ptime FROM headlines ORDER BY time DESC LIMIT 0,10

--- following two queries are for the voting poll. First one finds one active poll.
SELECT * FROM poll_list WHERE status='1'
--- second retrieves all possible answers for the poll
SELECT * FROM poll_answers WHERE pollid='1' ORDER BY count DESC


that's pretty much it.... i will have to add page statistic as well =((( i'm afraid it could go up to 30 queries per page after all components are in the place....

Right now it takes 0.00031 sec for the main page to be generated by PHP3 on WIN2K PROF.


Please, advice me if there is any way to reduce the amount of queries.



------------------
Alex D. G.
http://www.alexdg.com


Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > how many queries is too many?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway