Commit 9887da87 by Scott

Optimize local database by default

parent 37f557e3
......@@ -147,13 +147,14 @@
are not indexed efficiently. For example, this will enable browsing unanswered questions per
category. If your database becomes large, these queries could become costly.
Set QA_OPTIMIZE_LOCAL_DB to true if your web server and MySQL are running on the same box.
Set QA_OPTIMIZE_DISTANT_DB to false if your web server and MySQL are running on the same box.
When viewing a page on your site, this will use many simple MySQL queries instead of fewer
complex ones, which makes sense since there is no latency for localhost access.
Otherwise, set it to true if your web server and MySQL are far enough apart to create
significant latency. This will minimize the number of database queries as much as is possible,
even at the cost of significant additional processing at each end.
Set QA_OPTIMIZE_DISTANT_DB to true if your web server and MySQL are far enough apart to
create significant latency. This will minimize the number of database queries as much as
is possible, even at the cost of significant additional processing at each end.
The option QA_OPTIMIZE_LOCAL_DB is no longer used, since QA_OPTIMIZE_DISTANT_DB covers our uses.
Set QA_PERSISTENT_CONN_DB to true to use persistent database connections. Requires PHP 5.3.
Only use this if you are absolutely sure it is a good idea under your setup - generally it is
......@@ -167,7 +168,6 @@
define('QA_MAX_LIMIT_START', 19999);
define('QA_IGNORED_WORDS_FREQ', 10000);
define('QA_ALLOW_UNINDEXED_QUERIES', false);
define('QA_OPTIMIZE_LOCAL_DB', false);
define('QA_OPTIMIZE_DISTANT_DB', false);
define('QA_PERSISTENT_CONN_DB', false);
define('QA_DEBUG_PERFORMANCE', false);
......
......@@ -218,7 +218,7 @@
@define('QA_MAX_LIMIT_START', 19999);
@define('QA_IGNORED_WORDS_FREQ', 10000);
@define('QA_ALLOW_UNINDEXED_QUERIES', false);
@define('QA_OPTIMIZE_LOCAL_DB', false);
@define('QA_OPTIMIZE_LOCAL_DB', true); // no longer used
@define('QA_OPTIMIZE_DISTANT_DB', false);
@define('QA_PERSISTENT_CONN_DB', false);
@define('QA_DEBUG_PERFORMANCE', false);
......
......@@ -413,7 +413,7 @@
/*
The selectspec array can contain the elements below. See qa-db-selects.php for lots of examples.
The selectspec array can contain the elements below. See db/selects.php for lots of examples.
By default, qa_db_single_select() and qa_db_multi_select() return the data for each selectspec as a numbered
array of arrays, one per row. The array for each row has column names in the keys, and data in the values.
......@@ -448,12 +448,12 @@
Why does qa_db_multi_select() combine usually unrelated SELECT statements into a single query?
Because if the database and web servers are on different computers, there will be latency.
This way we ensure that every read pageview on the site requires only a single DB query, so
This way we ensure that every read pageview on the site requires as few DB queries as possible, so
that we pay for this latency only one time.
For writes we worry less, since the user is more likely to be expecting a delay.
If QA_OPTIMIZE_LOCAL_DB is set in qa-config.php, we assume zero latency and go back to
If QA_OPTIMIZE_DISTANT_DB is set to false in qa-config.php, we assume zero latency and go back to
simple queries, since this will allow both MySQL and PHP to provide quicker results.
*/
......@@ -490,7 +490,7 @@
// Perform simple queries if the database is local or there are only 0 or 1 selectspecs
if (QA_OPTIMIZE_LOCAL_DB || (count($selectspecs)<=1)) {
if (!QA_OPTIMIZE_DISTANT_DB || (count($selectspecs)<=1)) {
$outresults=array();
foreach ($selectspecs as $selectkey => $selectspec)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment