- Posts: 2
COMMUNITY FORUM
K2 does many queries to a DB!
- Yuri Popov
-
Topic Author
- Offline
- New Member
5 main categories and 1195 subcategories.
When i click the link (one of the main category), the site is very long loaded.
I enable Debug Mode and have seen, that the system does 1225 queries to a DB.
When i click the other link (other of the main category), the site is very-very-very long loaded.
I enable Debug Mode and have seen, that the system does 4243 queries to a DB.
I think it is bug.
How can I reduce CPU load?
p.S. i use k2 2.1
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
- Posts: 8743
Please Log in or Create an account to join the conversation.
- nuno miguel duarte santa antunes
-
- Offline
- New Member
- Posts: 1
Please Log in or Create an account to join the conversation.
- Bryan Smith
-
- Offline
- Premium Member
- Posts: 130
nuno miguel duarte santa antunes said:where can i change the "catalog mode"??? i have the same problem. my server blocked my site because it is loading a lot of CPU and it can damage other sites that are hosted there.
Please Log in or Create an account to join the conversation.
- Parth Lawate
-
- Offline
- New Member
- Posts: 18
We have benchmarked the site & it seems only K2 is to blame.. there is practically nothing else on the site..
Total articles are only 110 ..
Need help ASAP !
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
- Posts: 8743
1. Make sure that Joomla! cache is enabled.
2. Enable the system cache plugin.
3. Switch catalog mode setting to "Yes".
4. Check for any other extension causing performance isuues.
Parth Lawate said:What else can be done to reduce the Resource utilization of K2 ? We have a pretty small site by K2 standards hosted on Rochen.. using K2 primarily because of the categorization flexibility it offers. We have benchmarked the site & it seems only K2 is to blame.. there is practically nothing else on the site..
Total articles are only 110 ..
Need help ASAP !
Please Log in or Create an account to join the conversation.
- Parth Lawate
-
- Offline
- New Member
- Posts: 18
We have catalog mode set to no for our News & Blogs Sections where it needs to be no. Everywhere else its set to yes. Regarding Cache we have the Joomla cache ( global config ) set to yes & also have the the system cache plugin enabled..
Please Log in or Create an account to join the conversation.
- David R.
-
- Offline
- Premium Member
- Posts: 81
By the same token it makes sense to also have a "hasItem" flag.
Please Log in or Create an account to join the conversation.
- Parth Lawate
-
- Offline
- New Member
- Posts: 18
Maybe one of the devs can make a comment on this ?
Parth
David R. said:This could easily be optimized with the addition of a denormalized "hasChild" column to the k2_categories table. When a child is added or deleted, this flag would need to be updated. For situations like the ones described, it could be used to short circuit unnecessary queries for categories with no children.
By the same token it makes sense to also have a "hasItem" flag.
Please Log in or Create an account to join the conversation.
- Parth Lawate
-
- Offline
- New Member
- Posts: 18
For a site hosted at a Shared host like Rochen , should a site having around 250 visitors per day as per analytics and roughly 110 articles.. should it need a VPS ?
Please Log in or Create an account to join the conversation.
- David R.
-
- Offline
- Premium Member
- Posts: 81
Parth Lawate said:General Question ,
For a site hosted at a Shared host like Rochen , should a site having around 250 visitors per day as per analytics and roughly 110 articles.. should it need a VPS ?
Please Log in or Create an account to join the conversation.
- Parth Lawate
-
- Offline
- New Member
- Posts: 18
David R. said:No, 250 visitors a day is very low traffic.
Parth Lawate said:General Question , For a site hosted at a Shared host like Rochen , should a site having around 250 visitors per day as per analytics and roughly 110 articles.. should it need a VPS ?
Please Log in or Create an account to join the conversation.
- David R.
-
- Offline
- Premium Member
- Posts: 81
I feel strongly these are optimizations that would be very good for K2 performance since the ratio of read to write is typically going to be very high. Certainly caching is advisable, and "Catalog Mode -> Yes" is an acceptable switch for some people, but this would be far superior to that.
The only downside I can see to these suggestions is that there would need to be an integrity checker that goes through all the categories and items and validates the denormalized columns in the case that mysql has a problem, although that would not be a difficult utility to write at all.
So, in conclusion, storing a childcount and itemcount column in the categories would be all that's needed, and would provide great optimizations.
-No need to do count(*) for items
-No need to query for items when itemcount == 0
-No need to iterate on a subcategory if childcount == 0.
This could be *supercharged* with the addition of a category_item_xref table which would store a full list of all child categories for a category. It would simply flatten out the hierarchy so that you have a 1-M of all the child, subchild, subchild etc. categories for a particular category. Needless to say there would be no need to ever recurse given the availability of this table and associated index.
I haven't fully thought it through, but the itemcount in the category would eliminate concerns about displaying itemcount data, as you would be able to get everything required in one query/result set to display category and item data.
David R. said:This could easily be optimized with the addition of a denormalized "hasChild" column to the k2_categories table. When a child is added or deleted, this flag would need to be updated. For situations like the ones described, it could be used to short circuit unnecessary queries for categories with no children. By the same token it makes sense to also have a "hasItem" flag.
Please Log in or Create an account to join the conversation.
- Parth Lawate
-
- Offline
- New Member
- Posts: 18
Catalog mode isnt really very useful when you want to use the full power of K2 as a cck..
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
- Posts: 8743
Please Log in or Create an account to join the conversation.