Downsize CPU & DB usage in wordpress

i have created a smart interface WP based which we use to manage clients..
it uses a lot of information and data each time a client is returned / viewed.

it is a locked interface and does not have traffic spikes

Read More

in the past month i have seen major memory and CPU usage spikes so,
i have installed the debug bar and opended all the options.

What i am seeing is that each time wordpress includes wp-header-blog
and template-loader (or am i wrong?) – can i declare those once?

here is an example from the queries tab in the debug bar

'clientsocialurls'
require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/sagive-manager/category.php'), include('/themes/sagive-manager/tabs/tab-siteinfo.php'), get_page_by_title #47 (14.4ms)
SELECT ID FROM armnd_posts WHERE post_title = 'זמנהוף שירותי תרגום' AND post_type= 'cheques'

require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/sagive-manager/category.php'), include('/themes/sagive-manager/tabs/tab-cheques.php'), get_page_by_title #48 (3.9ms)
SELECT armnd_posts.* FROM armnd_posts WHERE 1=1 AND armnd_posts.post_type = 'attachments' AND (armnd_posts.post_status = 'publish') ORDER BY armnd_posts.post_date ASC 

require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/sagive-manager/category.php'), include('/themes/sagive-manager/tabs/tab-attachments.php'), get_posts, WP_Query->query, WP_Query->get_posts #49 (34.7ms)
SELECT post_id, meta_key, meta_value FROM armn_postmeta WHERE post_id IN (2073,2086,2093,2104,2109,2114,2119,2137,2143,2148,2154,2160,2165,2174,2178,2186,2274,2650,2708,3163,3356,3507,3644,3673,3893,3924,4039,4139,4286,4311,4515,4596,4666,4698,4722,4738,4740,4841,4860,4908,5219,5941,6086,6317) ORDER BY meta_id ASC

require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/sagive-manager/category.php'), include('/themes/sagive-manager/tabs/tab-attachments.php'), get_posts, WP_Query->query, WP_Query->get_posts, update_post_caches, update_postmeta_cache, update_meta_cache #50 (9.9ms)
SELECT armnd_posts.* FROM armnd_posts WHERE 1=1 AND armnd_posts.post_parent = 2119 AND armnd_posts.post_type = 'attachment' AND (armnd_posts.post_status = 'inherit') ORDER BY armnd_posts.post_date DESC 

require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/sagive-manager/category.php'), include('/themes/sagive-manager/tabs/tab-attachments.php'), get_posts, WP_Query->query, WP_Query->get_posts

does this means wordpress loads both files each time a query is called?
can i “Declare” them once to minimize memory usage and load time?

am i completlty missing the point and can you share some tips to downsize
the CPU usage & memory usage if its a given i cant use caching plugin.

Related posts

Leave a Reply

2 comments

  1. Sagive,

    1. wp-blog-header.php loaded in the index.php on each page request. AJAX calls included (if that’s what you mean “time after time”.
      Then it loads template-loader.php.
    2. This has nothing to do with the SQLs you see, and not with the “spikes”.
    3. Install the Query Monitor plugin to see your SQLs better in the Debug Bar.
    4. Do not publish sensitive information here (like the name of your client in the first SQL). 🙂
  2. HTTP is a stateless protocol and it will initialize the whole WordPress system each time a request hits any page in the server. Scripts like wp-blog-header.php, template-loader etc are required to properly initialize WordPress.