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`
|
||||
WHERE `rel` IN (%d, %d) AND `poll` != '' AND `network` IN ('%s', '%s', '%s', '%s', '%s', '%s')
|
||||
$sql_extra
|
||||
AND NOT `self` AND NOT `contact`.`blocked` AND NOT `contact`.`readonly` AND NOT `contact`.`archive`
|
||||
AND NOT `user`.`account_expired` AND NOT `user`.`account_removed` $abandon_sql ORDER BY RAND()",
|
||||
$contacts = q("SELECT `contact`.`id` FROM `user`
|
||||
STRAIGHT_JOIN `contact`
|
||||
ON `contact`.`uid` = `user`.`uid` AND `contact`.`rel` IN (%d, %d) AND `contact`.`poll` != ''
|
||||
AND `contact`.`network` IN ('%s', '%s', '%s', '%s', '%s', '%s') $sql_extra
|
||||
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_FRIEND),
|
||||
dbesc(NETWORK_DFRN),
|
||||
|
|
|
@ -141,25 +141,44 @@ class dba {
|
|||
public function log_index($query) {
|
||||
$a = get_app();
|
||||
|
||||
if (($a->config["system"]["db_log_index"] == "") OR ($a->config["system"]["db_log_index_watch"] == "") OR
|
||||
(intval($a->config["system"]["db_loglimit_index"]) == 0)) {
|
||||
if ($a->config["system"]["db_log_index"] == "") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't explain an explain statement
|
||||
if (strtolower(substr($query, 0, 7)) == "explain") {
|
||||
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);
|
||||
if (!dbm::is_result($r)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$watchlist = explode(',', $a->config["system"]["db_log_index_watch"]);
|
||||
$blacklist = explode(',', $a->config["system"]["db_log_index_blacklist"]);
|
||||
|
||||
foreach ($r AS $row) {
|
||||
if (in_array($row['key'], $watchlist) AND
|
||||
($row['rows'] >= intval($a->config["system"]["db_loglimit_index"]))) {
|
||||
if ((intval($a->config["system"]["db_loglimit_index"]) > 0)) {
|
||||
$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);
|
||||
@file_put_contents($a->config["system"]["db_log_index"], datetime_convert()."\t".
|
||||
$row['key']."\t".$row['rows']."\t".
|
||||
|
|
|
@ -595,6 +595,8 @@ function db_definition($charset) {
|
|||
"addr_uid" => array("addr(32)", "uid"),
|
||||
"nurl_uid" => array("nurl(32)", "uid"),
|
||||
"nick_uid" => array("nick(32)", "uid"),
|
||||
"dfrn-id" => array("dfrn-id"),
|
||||
"issued-id" => array("issued-id"),
|
||||
)
|
||||
);
|
||||
$database["conv"] = array(
|
||||
|
@ -676,6 +678,7 @@ function db_definition($charset) {
|
|||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
"addr" => array("addr(32)"),
|
||||
"url" => array("url"),
|
||||
)
|
||||
);
|
||||
$database["ffinder"] = array(
|
||||
|
@ -764,6 +767,7 @@ function db_definition($charset) {
|
|||
"name" => array("name(32)"),
|
||||
"nick" => array("nick(32)"),
|
||||
"addr" => array("addr(32)"),
|
||||
"hide_network_updated" => array("hide", "network", "updated"),
|
||||
"updated" => array("updated"),
|
||||
)
|
||||
);
|
||||
|
@ -804,6 +808,7 @@ function db_definition($charset) {
|
|||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
"contactid" => array("contact-id"),
|
||||
"gid_contactid" => array("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"),
|
||||
"deleted_changed" => array("deleted","changed"),
|
||||
"uid_wall_changed" => array("uid","wall","changed"),
|
||||
"wall_uid_changed" => array("wall","uid","changed"),
|
||||
"uid_eventid" => array("uid","event-id"),
|
||||
"uid_authorlink" => array("uid","author-link"),
|
||||
"uid_ownerlink" => array("uid","owner-link"),
|
||||
|
@ -1066,10 +1072,10 @@ function db_definition($charset) {
|
|||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
"uid_hash" => array("uid", "hash"),
|
||||
"hash_uid" => array("hash", "uid"),
|
||||
"seen_uid_date" => array("seen", "uid", "date"),
|
||||
"type_uid_link" => array("type", "uid", "link"),
|
||||
"uid_date" => array("uid", "date"),
|
||||
"uid_type_link" => array("uid", "type", "link"),
|
||||
)
|
||||
);
|
||||
$database["notify-threads"] = array(
|
||||
|
@ -1245,6 +1251,7 @@ function db_definition($charset) {
|
|||
),
|
||||
"indexes" => array(
|
||||
"PRIMARY" => array("id"),
|
||||
"uid_is-default" => array("uid", "is-default"),
|
||||
)
|
||||
);
|
||||
$database["profile_check"] = array(
|
||||
|
|
Loading…
Reference in a new issue