diff options
author | Michael Vogel <icarus@dabo.de> | 2012-05-26 03:21:07 +0200 |
---|---|---|
committer | Michael Vogel <icarus@dabo.de> | 2012-05-26 03:21:07 +0200 |
commit | 49512105082dde72553f4250e6284920612cc6b8 (patch) | |
tree | e6222e7ca809b116af44d006218271bc36b5c009 /include | |
parent | a71e3134bf7250b60cafd1e51098eea70c3459de (diff) | |
download | volse-hubzilla-49512105082dde72553f4250e6284920612cc6b8.tar.gz volse-hubzilla-49512105082dde72553f4250e6284920612cc6b8.tar.bz2 volse-hubzilla-49512105082dde72553f4250e6284920612cc6b8.zip |
Speed optimisation by enabling the posibility of the MySQL fulltext engine
Diffstat (limited to 'include')
-rw-r--r-- | include/api.php | 20 | ||||
-rw-r--r-- | include/dba.php | 4 |
2 files changed, 16 insertions, 8 deletions
diff --git a/include/api.php b/include/api.php index f58a91a72..5697fbdbc 100644 --- a/include/api.php +++ b/include/api.php @@ -976,7 +976,7 @@ $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); $max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0); //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); - + $start = $page*$count; //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); @@ -985,11 +985,19 @@ $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` regexp '%s' or `tag` regexp '%s' or tag regexp '%s' )) ", - dbesc($myurl . '$'), - dbesc($myurl . '\\]'), - dbesc($diasp_url . '\\]') - ); + + if (get_config('system','use_fulltext_engine')) + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($diasp_url)) + ); + else + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", + dbesc(protect_sprintf('%' . $myurl)), + dbesc(protect_sprintf('%' . $myurl . '\\]%')), + dbesc(protect_sprintf('%' . $diasp_url . '\\]%')) + ); if ($max_id > 0) $sql_extra .= ' AND `item`.`id` <= '.intval($max_id); diff --git a/include/dba.php b/include/dba.php index 7ecce7270..c19d4a8fc 100644 --- a/include/dba.php +++ b/include/dba.php @@ -77,14 +77,14 @@ class dba { $this->error = ''; - //@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND); + @file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND); if($this->mysqli) $result = @$this->db->query($sql); else $result = @mysql_query($sql,$this->db); - //@file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND); + @file_put_contents("/tmp/friendica-db.log", datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND); if($this->mysqli) { if($this->db->errno) |