Skip to content
Snippets Groups Projects
Commit a4561d78 authored by Joe Oblivian's avatar Joe Oblivian Committed by agata
Browse files

Performance tweaks:

- Cache more aggressively
- Use persistent connections

Profiling: changing the define AI_DB_PROFILER to true will enable query logging (use with caution!)
parent b9f9b389
Branches
No related tags found
No related merge requests found
......@@ -7,6 +7,9 @@ RewriteCond %{HTTP_HOST} ^ventitre\.noblogs\.org [NC]
RewriteRule ^/?(.*) http://www.ventitre.org/$1 [L,R=301,NE]
####
#avoid inspection of queries log
RewriteRule ^/noblogs_queries.* /ancheno [L,R=404]
# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
RewriteRule ^gallery/([0-9]+)/(previews|previews-med)/(.*)$ oldgal/$1/$2/$3 [L]
......@@ -17,7 +20,8 @@ RewriteRule ^resource/[^/]+/download/(.*)$ wp-includes/ms-files.php?file=2010/08
# BEGIN WPSuperCache
<IfModule mod_rewrite.c>
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_URI} !^.*[^/]$
# Commented in order to cache more
# RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
......@@ -31,7 +35,8 @@ RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/%{HTTP:X-Forwarded-Proto}/$1/index.html.gz -f
RewriteRule ^(.*) "/wp-content/cache/supercache/%{HTTP_HOST}/%{HTTP:X-Forwarded-Proto}/$1/index.html.gz" [L]
RewriteCond %{REQUEST_URI} !^.*[^/]$
#Commented in order to cache more
#RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
......
<?php
// Common settings
$wpdb->save_queries = false;
$wpdb->persistent = false;
$wpdb->persistent = true;
$wpdb->max_connections = 30;
define("NOBLOGS_BACKEND_CONFIG", "/etc/noblogs/backends");
......@@ -22,4 +21,3 @@ $wpdb->add_database(array(
));
$wpdb_reverse_backend_map = noblogs_load_backends(NOBLOGS_BACKEND_CONFIG, $wpdb->hash_map);
<?php
//AI patch: set to true if you want to activate query profiling
define('AI_DB_PROFILER', false);
/*
Plugin Name: HyperDB
......@@ -1441,6 +1443,23 @@ class hyperdb extends wpdb {
} // class hyperdb
$wpdb = new hyperdb();
/**
* AI custom: Logs all queries for debugging purposes
*/
function ai_log_db_queries($query, $time, $backtrace=null, hyperdb $obj ) {
$fh = fopen( ABSPATH . '/profiling/noblogs_queries_'. date('Ymd') . '.log', 'a');
if (!$fh) {
return array($query, $time, $backtrace);
}
fwrite($fh, sprintf("##\n#Date: %s\n#Query time: %s\n%s\n", date('r'), $time, $query));
fclose($fh);
return array($query, $time, $backtrace);
}
$wpdb = new hyperdb();
if ( AI_DB_PROFILER === true ) {
$wpdb->save_queries = true;
$wpdb->save_query_callback = 'ai_log_db_queries';
}
require( DB_CONFIG_FILE );
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment