query optimisations for notifications - use a specific index only
This commit is contained in:
parent
423274b923
commit
a86b260f73
@ -51,9 +51,11 @@ class Hq extends \Zotlabs\Web\Controller {
|
|||||||
$item_normal = item_normal();
|
$item_normal = item_normal();
|
||||||
$item_normal_update = item_normal_update();
|
$item_normal_update = item_normal_update();
|
||||||
|
|
||||||
|
$use_index = db_use_index('created');
|
||||||
|
|
||||||
if(! $item_hash) {
|
if(! $item_hash) {
|
||||||
$r = q("SELECT mid FROM item
|
$r = q("SELECT mid FROM item $use_index
|
||||||
WHERE uid = %d
|
WHERE uid = %d $item_normal
|
||||||
AND mid = parent_mid
|
AND mid = parent_mid
|
||||||
ORDER BY created DESC LIMIT 1",
|
ORDER BY created DESC LIMIT 1",
|
||||||
intval(local_channel())
|
intval(local_channel())
|
||||||
|
@ -320,7 +320,9 @@ class Ping extends \Zotlabs\Web\Controller {
|
|||||||
if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) {
|
if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
$r = q("SELECT * FROM item
|
$use_index = db_use_index('uid_item_unseen');
|
||||||
|
|
||||||
|
$r = q("SELECT * FROM item $use_index
|
||||||
WHERE item_unseen = 1 and uid = %d $item_normal
|
WHERE item_unseen = 1 and uid = %d $item_normal
|
||||||
AND author_xchan != '%s'
|
AND author_xchan != '%s'
|
||||||
ORDER BY created DESC limit 300",
|
ORDER BY created DESC limit 300",
|
||||||
@ -492,8 +494,10 @@ class Ping extends \Zotlabs\Web\Controller {
|
|||||||
$t3 = dba_timer();
|
$t3 = dba_timer();
|
||||||
|
|
||||||
if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) {
|
if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) {
|
||||||
|
|
||||||
|
$use_index = db_use_index('uid_item_unseen');
|
||||||
|
|
||||||
$r = q("SELECT id, item_wall FROM item
|
$r = q("SELECT id, item_wall FROM item $use_index
|
||||||
WHERE item_unseen = 1 and uid = %d
|
WHERE item_unseen = 1 and uid = %d
|
||||||
$item_normal
|
$item_normal
|
||||||
AND author_xchan != '%s'",
|
AND author_xchan != '%s'",
|
||||||
|
@ -321,6 +321,10 @@ function db_concat($fld, $sep) {
|
|||||||
return \DBA::$dba->concat($fld, $sep);
|
return \DBA::$dba->concat($fld, $sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function db_use_index($str) {
|
||||||
|
return \DBA::$dba->use_index($str);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Execute a SQL query with printf style args.
|
* @brief Execute a SQL query with printf style args.
|
||||||
*
|
*
|
||||||
|
@ -111,6 +111,15 @@ class dba_pdo extends dba_driver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function use_index($str) {
|
||||||
|
if($this->driver_dbtype === 'pgsql') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 'USE INDEX( ' . $str . ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function quote_interval($txt) {
|
function quote_interval($txt) {
|
||||||
if($this->driver_dbtype === 'pgsql') {
|
if($this->driver_dbtype === 'pgsql') {
|
||||||
return "'$txt'";
|
return "'$txt'";
|
||||||
|
@ -52,9 +52,6 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if(! page_load) {
|
if(! page_load) {
|
||||||
if($(this).parent().attr('id') !== 'nav-pubs-menu')
|
|
||||||
$(this).fadeOut();
|
|
||||||
|
|
||||||
getData(b64mid, notify_id);
|
getData(b64mid, notify_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user