I just read that some content management systems are running more than 30 queries to generate a regular page. Some said they were making several hundred database calls. I just could not believe that. How many queries are generating your pages? And why so many?


pr0gr4mm3r posted this at 00:45 — 2nd November 2008.
He has: 1,421 posts
Joined: Sep 2006
My blog homepage (running WordPress) run 18 queries, and an article page runs 28. I'm guessing that it runs so many because of the plugins...they are on their own to get the data they need, so I'm sure there are redundant calls. Plus, simple template tags that gets a setting like the blog path is a query every time it's ran - even if in the template several times. I haven't had the time to tweak it, and I'll worry about it more when my blog pulls enough traffic to be a problem.
My own sites that I do from scratch doesn't do nearly that many. I would say maybe 5 tops.
PHP Starter
decibel.places posted this at 02:26 — 2nd November 2008.
He has: 1,550 posts
Joined: Jun 2008
Drupal is a well-known sql query hog - I would guess in the range of 50+ queries for a page...
Yup, those nifty modules add their own set of queries...
Drupal also has methods to reduce the page load, including caching some javascript and css, and "throttle" which will reduce or turn off selected modules during heavy traffic.
Some developers will cache all static content, using memcache and/or distributed server architecture.
I met with developers at Northpoint Solutions who are using combinations of these techniques to create Drupal sites capable of handling 1,000,000+ page views/minute!
web hosting india posted this at 10:06 — 15th January 2009.
They have: 5 posts
Joined: Jan 2009
Most of the time I had about 60 queries.. But sometimes (very often) it goes upto 100 even..
The site becomes slow and little unresponsive at that time..
Does anyone else also experience the same issue?
Cheap cPanel Web Hosting with 99.9% uptime - Web Hosting India
Greg K posted this at 18:13 — 15th January 2009.
He has: 1,911 posts
Joined: Nov 2003
Funny this topic came back up. Last night I added in some code on a site, and it did an average of 60 calls per page. One page that loads in all product info to do comparisons, topped out at 1300 calls for the one page (PHP was actually executing for just over 4 seconds). Needless to say, this site will get looked over to better optimize it's code...
Also, something to consider on a high traffic production site, not only the number of queries, but number of actual database connections and makings sure queries are freed up when done using them.
Also optimizing the queries (not actual code, generalized for easier reading)
SELECT UserID FROM UsersOnline WHERE LastAccess {within 5 minutes}
{Loop thorugh all results}
SELECT * FROM Users WHERE UserID={rs.UserID}
SELECT Thumbnail FROM Files WHERE Type='Atavar' AND ParentID={rs.UserID}
{Display user pic/info}
Now if 20 people are online, that bit makes 41 queries, where it could be done in one query (ok, i'm a bit tired, you may have to look up the exact, but here is the gist)
SELECT u.*, f.thumb FROM Users uLEFT JOIN Files f on f.ParentID=u.UserID
WHERE u.UserID IN (SELECT UserID) FROM UsersOnline WHERE LastAccess {within 5 minutes})
Oh the resources saved! When you have a query that is based upon data being looped upon from an earlier query, it is usually a good spot for a JOIN! Always have the DB server do as much as it can to limit and format your results!
-Greg
[This space intentionally left blank]
Cool Geek Supplies: www.ThinkGeek.com
jane0109 posted this at 11:04 — 1st February 2009.
They have: 5 posts
Joined: Feb 2009
I try not to be clog with querries.
LisaRole posted this at 22:15 — 8th May 2009.
They have: 19 posts
Joined: Feb 2009
My page have 30+ quires, sometimes i do more on other sites.
masudkarim posted this at 03:20 — 9th May 2009.
They have: 1 posts
Joined: May 2009
At some stage in the code you will fill the report eg. with
JasperFillManager.fillReport(jr, reportParameters,
dataSource);
All you have to make sure is that the reportParameters contains all the
values
from your queries in a Map.
Eg. with totalCount 100
and that your jrxml references the parameter with $P{totalCount}. Use a text
field in iReport but change from $F to $P ...
Test it out with a hardcoded Map first and then fill the map from your data.
[url=http://www.scooterandwheelchairstore.com]wheelchair lifts[/url]
[url=http://www.bogar.nl/makeup.html]permanente make up[/url]
Megatron posted this at 18:05 — 21st May 2009.
They have: 2 posts
Joined: May 2009
The number of queries doesn't really matter... of course it should be as low as possible, but if they are optimized 1000 queries will be faster then 1 bad query.
I've worked with systems that did 6000 queries for a youtube like home page because of bad "concept" in the background code. Totally WTF when I first realized the number, but the queries were optimized and the site worked normaly even during high loads.
Transformers 2
greg posted this at 18:48 — 21st May 2009.
He has: 1,580 posts
Joined: Nov 2005
Hmm, even the most complex sites with lots of information requirements I have built have not had more than 3 queries on a page.
Initially designing the database with your known site output is key. Then you don't need many queries to access the data.
Signature links on this forum are NO-follow! - This means spam is futile!
delkan15 posted this at 09:12 — 29th May 2009.
They have: 4 posts
Joined: May 2009
My site has approx 40 queries.