Some more changed indexes and improved queries
This commit is contained in:
parent
85397f3bb9
commit
e16afc0450
|
@ -239,11 +239,13 @@ function cron_poll_contacts($argc, $argv) {
|
||||||
: ''
|
: ''
|
||||||
);
|
);
|
||||||
|
|
||||||
$contacts = q("SELECT `contact`.`id` FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
$contacts = q("SELECT `contact`.`id` FROM `user`
|
||||||
WHERE `rel` IN (%d, %d) AND `poll` != '' AND `network` IN ('%s', '%s', '%s', '%s', '%s', '%s')
|
STRAIGHT_JOIN `contact`
|
||||||
$sql_extra
|
ON `contact`.`uid` = `user`.`uid` AND `contact`.`rel` IN (%d, %d) AND `contact`.`poll` != ''
|
||||||
AND NOT `self` AND NOT `contact`.`blocked` AND NOT `contact`.`readonly` AND NOT `contact`.`archive`
|
AND `contact`.`network` IN ('%s', '%s', '%s', '%s', '%s', '%s') $sql_extra
|
||||||
AND NOT `user`.`account_expired` AND NOT `user`.`account_removed` $abandon_sql ORDER BY RAND()",
|
AND NOT `contact`.`self` AND NOT `contact`.`blocked` AND NOT `contact`.`readonly`
|
||||||
|
AND NOT `contact`.`archive`
|
||||||
|
WHERE NOT `user`.`account_expired` AND NOT `user`.`account_removed` $abandon_sql ORDER BY RAND()",
|
||||||
intval(CONTACT_IS_SHARING),
|
intval(CONTACT_IS_SHARING),
|
||||||
intval(CONTACT_IS_FRIEND),
|
intval(CONTACT_IS_FRIEND),
|
||||||
dbesc(NETWORK_DFRN),
|
dbesc(NETWORK_DFRN),
|
||||||
|
|
|
@ -141,25 +141,44 @@ class dba {
|
||||||
public function log_index($query) {
|
public function log_index($query) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
if (($a->config["system"]["db_log_index"] == "") OR ($a->config["system"]["db_log_index_watch"] == "") OR
|
if ($a->config["system"]["db_log_index"] == "") {
|
||||||
(intval($a->config["system"]["db_loglimit_index"]) == 0)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't explain an explain statement
|
||||||
if (strtolower(substr($query, 0, 7)) == "explain") {
|
if (strtolower(substr($query, 0, 7)) == "explain") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only do the explain on "select", "update" and "delete"
|
||||||
|
if (!in_array(strtolower(substr($query, 0, 6)), array("select", "update", "delete"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$r = $this->q("EXPLAIN ".$query);
|
$r = $this->q("EXPLAIN ".$query);
|
||||||
if (!dbm::is_result($r)) {
|
if (!dbm::is_result($r)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$watchlist = explode(',', $a->config["system"]["db_log_index_watch"]);
|
$watchlist = explode(',', $a->config["system"]["db_log_index_watch"]);
|
||||||
|
$blacklist = explode(',', $a->config["system"]["db_log_index_blacklist"]);
|
||||||
|
|
||||||
foreach ($r AS $row) {
|
foreach ($r AS $row) {
|
||||||
if (in_array($row['key'], $watchlist) AND
|
if ((intval($a->config["system"]["db_loglimit_index"]) > 0)) {
|
||||||
($row['rows'] >= intval($a->config["system"]["db_loglimit_index"]))) {
|
$log = (in_array($row['key'], $watchlist) AND
|
||||||
|
($row['rows'] >= intval($a->config["system"]["db_loglimit_index"])));
|
||||||
|
} else
|
||||||
|
$log = false;
|
||||||
|
|
||||||
|
if ((intval($a->config["system"]["db_loglimit_index_high"]) > 0) AND ($row['rows'] >= intval($a->config["system"]["db_loglimit_index_high"]))) {
|
||||||
|
$log = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($row['key'], $blacklist) OR ($row['key'] == "")) {
|
||||||
|
$log = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($log) {
|
||||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
@file_put_contents($a->config["system"]["db_log_index"], datetime_convert()."\t".
|
@file_put_contents($a->config["system"]["db_log_index"], datetime_convert()."\t".
|
||||||
$row['key']."\t".$row['rows']."\t".
|
$row['key']."\t".$row['rows']."\t".
|
||||||
|
|
|
@ -595,6 +595,8 @@ function db_definition($charset) {
|
||||||
"addr_uid" => array("addr(32)", "uid"),
|
"addr_uid" => array("addr(32)", "uid"),
|
||||||
"nurl_uid" => array("nurl(32)", "uid"),
|
"nurl_uid" => array("nurl(32)", "uid"),
|
||||||
"nick_uid" => array("nick(32)", "uid"),
|
"nick_uid" => array("nick(32)", "uid"),
|
||||||
|
"dfrn-id" => array("dfrn-id"),
|
||||||
|
"issued-id" => array("issued-id"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$database["conv"] = array(
|
$database["conv"] = array(
|
||||||
|
@ -676,6 +678,7 @@ function db_definition($charset) {
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
"addr" => array("addr(32)"),
|
"addr" => array("addr(32)"),
|
||||||
|
"url" => array("url"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$database["ffinder"] = array(
|
$database["ffinder"] = array(
|
||||||
|
@ -764,6 +767,7 @@ function db_definition($charset) {
|
||||||
"name" => array("name(32)"),
|
"name" => array("name(32)"),
|
||||||
"nick" => array("nick(32)"),
|
"nick" => array("nick(32)"),
|
||||||
"addr" => array("addr(32)"),
|
"addr" => array("addr(32)"),
|
||||||
|
"hide_network_updated" => array("hide", "network", "updated"),
|
||||||
"updated" => array("updated"),
|
"updated" => array("updated"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -804,6 +808,7 @@ function db_definition($charset) {
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
|
"contactid" => array("contact-id"),
|
||||||
"gid_contactid" => array("gid", "contact-id"),
|
"gid_contactid" => array("gid", "contact-id"),
|
||||||
"uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
|
"uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
|
||||||
)
|
)
|
||||||
|
@ -953,6 +958,7 @@ function db_definition($charset) {
|
||||||
"contactid_verb" => array("contact-id","verb"),
|
"contactid_verb" => array("contact-id","verb"),
|
||||||
"deleted_changed" => array("deleted","changed"),
|
"deleted_changed" => array("deleted","changed"),
|
||||||
"uid_wall_changed" => array("uid","wall","changed"),
|
"uid_wall_changed" => array("uid","wall","changed"),
|
||||||
|
"wall_uid_changed" => array("wall","uid","changed"),
|
||||||
"uid_eventid" => array("uid","event-id"),
|
"uid_eventid" => array("uid","event-id"),
|
||||||
"uid_authorlink" => array("uid","author-link"),
|
"uid_authorlink" => array("uid","author-link"),
|
||||||
"uid_ownerlink" => array("uid","owner-link"),
|
"uid_ownerlink" => array("uid","owner-link"),
|
||||||
|
@ -1066,10 +1072,10 @@ function db_definition($charset) {
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
"uid_hash" => array("uid", "hash"),
|
"hash_uid" => array("hash", "uid"),
|
||||||
"seen_uid_date" => array("seen", "uid", "date"),
|
"seen_uid_date" => array("seen", "uid", "date"),
|
||||||
"type_uid_link" => array("type", "uid", "link"),
|
|
||||||
"uid_date" => array("uid", "date"),
|
"uid_date" => array("uid", "date"),
|
||||||
|
"uid_type_link" => array("uid", "type", "link"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$database["notify-threads"] = array(
|
$database["notify-threads"] = array(
|
||||||
|
@ -1245,6 +1251,7 @@ function db_definition($charset) {
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
|
"uid_is-default" => array("uid", "is-default"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$database["profile_check"] = array(
|
$database["profile_check"] = array(
|
||||||
|
|
Loading…
Reference in a new issue