Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
9887da87
Commit
9887da87
authored
Feb 14, 2016
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize local database by default
parent
37f557e3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
qa-config-example.php
qa-config-example.php
+5
-5
qa-base.php
qa-include/qa-base.php
+1
-1
qa-db.php
qa-include/qa-db.php
+4
-4
No files found.
qa-config-example.php
View file @
9887da87
...
...
@@ -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 tru
e if your web server and MySQL are running on the same box.
Set QA_OPTIMIZE_
DISTANT_DB to fals
e 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
);
...
...
qa-include/qa-base.php
View file @
9887da87
...
...
@@ -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
);
...
...
qa-include/qa-db.php
View file @
9887da87
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment