Keyword

Some minor DB optimizations...

  • Marcos Ortega Miranda
  • Marcos Ortega Miranda's Avatar Topic Author
  • Offline
  • New Member
More
13 years 11 months ago #88872 by Marcos Ortega Miranda
Some minor DB optimizations... was created by Marcos Ortega Miranda
I've had a look at K2's DB performance and found that there are some optimizations that could be made:Some indexes for better/faster access:ALTER TABLE `jos_k2_comments` ADD INDEX
`pub_id` (`published`, `itemID`);
ALTER TABLE `jos_k2_tags` ADD INDEX
`pub_id` (`published`, `id`);
ALTER TABLE `jos_k2_items` ADD INDEX
`state_access` ( `published` , `trash` , `access` , `publish_up` , `publish_down`
, `catid`, `featured`, `created` DESC);        
In the file /components/com_k2/models/item.php line 779, change$query="SELECT * FROM #__k2_tags as tags WHERE tags.published=1 AND tags.id IN (SELECT tagID FROM #__k2_tags_xref WHERE itemID=".(int)$itemID.")";for $query="SELECT * FROM #__k2_tags as tags JOIN #__k2_tags_xref ON tags.id = tagID AND tags.published=1 AND itemID=".(int)$itemID;

Please Log in or Create an account to join the conversation.

More
13 years 11 months ago #88873 by william white
Replied by william white on topic Some minor DB optimizations...
If you create an index to mysql table, does mysql do as some database prgrams do and optomze the query and use the best index if it exists and if it doesnt have the necessary index, stop and create a tempory one to produce the desired results?
i come from vfp and rushmore optimization environments

Please Log in or Create an account to join the conversation.

  • Marcos Ortega Miranda
  • Marcos Ortega Miranda's Avatar Topic Author
  • Offline
  • New Member
More
13 years 11 months ago #88874 by Marcos Ortega Miranda
Replied by Marcos Ortega Miranda on topic Some minor DB optimizations...
PHP is a acripting language, so my guess is that DB accesses are treated dynamically, and therefore they choose the best index that already exists, but AFAIK, mysql doesn't create 'temporary indexes'...

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum