: ''
);
- $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),
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".
"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(
"indexes" => array(
"PRIMARY" => array("id"),
"addr" => array("addr(32)"),
+ "url" => array("url"),
)
);
$database["ffinder"] = array(
"name" => array("name(32)"),
"nick" => array("nick(32)"),
"addr" => array("addr(32)"),
+ "hide_network_updated" => array("hide", "network", "updated"),
"updated" => array("updated"),
)
);
),
"indexes" => array(
"PRIMARY" => array("id"),
+ "contactid" => array("contact-id"),
"gid_contactid" => array("gid", "contact-id"),
"uid_gid_contactid" => array("UNIQUE", "uid", "gid", "contact-id"),
)
"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"),
),
"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(
),
"indexes" => array(
"PRIMARY" => array("id"),
+ "uid_is-default" => array("uid", "is-default"),
)
);
$database["profile_check"] = array(