Merge pull request #1593 from annando/1505-api-speedup
SQL speed increase for query and search.
This commit is contained in:
commit
f384a1d8ab
|
@ -1162,7 +1162,7 @@
|
||||||
if ($conversation_id > 0)
|
if ($conversation_id > 0)
|
||||||
$sql_extra .= ' AND `item`.`parent` = '.intval($conversation_id);
|
$sql_extra .= ' AND `item`.`parent` = '.intval($conversation_id);
|
||||||
|
|
||||||
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
|
$r = q("SELECT STRAIGHT_JOIN `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
|
||||||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
|
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
|
||||||
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||||
|
|
|
@ -7,7 +7,7 @@ function search_saved_searches() {
|
||||||
if(! feature_enabled(local_user(),'savedsearch'))
|
if(! feature_enabled(local_user(),'savedsearch'))
|
||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
$r = q("select `id`,`term` from `search` WHERE `uid` = %d",
|
$r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ function search_init(&$a) {
|
||||||
|
|
||||||
if(local_user()) {
|
if(local_user()) {
|
||||||
if(x($_GET,'save') && $search) {
|
if(x($_GET,'save') && $search) {
|
||||||
$r = q("select * from `search` where `uid` = %d and `term` = '%s' limit 1",
|
$r = q("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
dbesc($search)
|
dbesc($search)
|
||||||
);
|
);
|
||||||
if(! count($r)) {
|
if(! count($r)) {
|
||||||
q("insert into `search` ( `uid`,`term` ) values ( %d, '%s') ",
|
q("INSERT INTO `search` (`uid`,`term`) VALUES ( %d, '%s')",
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
dbesc($search)
|
dbesc($search)
|
||||||
);
|
);
|
||||||
|
@ -135,7 +135,7 @@ function search_content(&$a) {
|
||||||
if($tag) {
|
if($tag) {
|
||||||
logger("Start tag search for '".$search."'", LOGGER_DEBUG);
|
logger("Start tag search for '".$search."'", LOGGER_DEBUG);
|
||||||
|
|
||||||
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
|
$r = q("SELECT STRAIGHT_JOIN `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
|
||||||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
|
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
|
||||||
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
|
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
|
||||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||||
|
@ -156,7 +156,7 @@ function search_content(&$a) {
|
||||||
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
|
$r = q("SELECT STRAIGHT_JOIN `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
|
||||||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
|
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
|
||||||
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
|
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
|
||||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||||
|
|
Loading…
Reference in a new issue