summaryrefslogtreecommitdiffstats
path: root/src/libs/zbxdbhigh/db.c
diff options
context:
space:
mode:
authoralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-11-27 10:39:32 +0000
committeralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-11-27 10:39:32 +0000
commit60562a3c1bc3a079d99e9cf07bbb219dd59b5d38 (patch)
tree9637390572e2a53f130bb8301580ce5703cbbffc /src/libs/zbxdbhigh/db.c
parent1bd6dc62e58531f845b82f6192f7eb009aea400f (diff)
downloadzabbix-60562a3c1bc3a079d99e9cf07bbb219dd59b5d38.tar.gz
zabbix-60562a3c1bc3a079d99e9cf07bbb219dd59b5d38.tar.xz
zabbix-60562a3c1bc3a079d99e9cf07bbb219dd59b5d38.zip
- [DEV-84] more efficient SQL for selection of the last events (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@5104 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxdbhigh/db.c')
-rw-r--r--src/libs/zbxdbhigh/db.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index 71bb8b81..22c47fd5 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -310,7 +310,10 @@ void get_latest_event_status(zbx_uint64_t triggerid, int *prev_status, int *late
zabbix_log(LOG_LEVEL_DEBUG,"In get_latest_event_status(triggerid:" ZBX_FS_UI64,
triggerid);
- zbx_snprintf(sql,sizeof(sql),"select eventid,value,clock from events where source=%d and object=%d and objectid=" ZBX_FS_UI64 " order by clock desc",
+ /* Object and objectid are used for efficient sort by the same index as in wehere condition */
+ zbx_snprintf(sql,sizeof(sql),"select eventid,value,clock,object,objectid from events where source=%d and object=%d and objectid=" ZBX_FS_UI64 " order by object desc,objectid desc,clock desc",
+ /* The SQL is inefficient */
+/* zbx_snprintf(sql,sizeof(sql),"select eventid,value,clock from events where source=%d and object=%d and objectid=" ZBX_FS_UI64 " order by clock desc",*/
EVENT_SOURCE_TRIGGERS,
EVENT_OBJECT_TRIGGER,
triggerid);