diff --git a/src/libs/zbxdbcache/dbconfig.c b/src/libs/zbxdbcache/dbconfig.c
index 6960531ac5..f545057939 100644
--- a/src/libs/zbxdbcache/dbconfig.c
+++ b/src/libs/zbxdbcache/dbconfig.c
@@ -3363,7 +3363,7 @@ static void	DCsync_triggers(zbx_dbsync_t *sync)
 	ZBX_DC_TRIGGER	*trigger;
 
 	int		found, ret;
-	zbx_uint64_t	triggerid;
+	zbx_uint64_t	triggerid, last_triggerid = 0;
 
 	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
 
@@ -3375,6 +3375,11 @@ static void	DCsync_triggers(zbx_dbsync_t *sync)
 
 		ZBX_STR2UINT64(triggerid, row[0]);
 
+		if (triggerid == last_triggerid)
+			continue;
+
+		last_triggerid = triggerid;
+
 		trigger = (ZBX_DC_TRIGGER *)DCfind_id(&config->triggers, triggerid, sizeof(ZBX_DC_TRIGGER), &found);
 
 		/* store new information in trigger structure */
@@ -4519,7 +4524,7 @@ static void	DCsync_trigger_tags(zbx_dbsync_t *sync)
 	zbx_uint64_t		rowid;
 	unsigned char		tag;
 	int			found, ret, index;
-	zbx_uint64_t		triggerid, triggertagid;
+	zbx_uint64_t		triggerid, last_triggertagid = 0, triggertagid;
 	ZBX_DC_TRIGGER		*trigger;
 	zbx_dc_trigger_tag_t	*trigger_tag;
 
@@ -4531,12 +4536,19 @@ static void	DCsync_trigger_tags(zbx_dbsync_t *sync)
 		if (ZBX_DBSYNC_ROW_REMOVE == tag)
 			break;
 
+		ZBX_STR2UINT64(triggertagid, row[0]);
+
+		if (triggertagid == last_triggertagid)
+			continue;
+
+		last_triggertagid = triggertagid;
+
 		ZBX_STR2UINT64(triggerid, row[1]);
 
 		if (NULL == (trigger = (ZBX_DC_TRIGGER *)zbx_hashset_search(&config->triggers, &triggerid)))
 			continue;
 
-		ZBX_STR2UINT64(triggertagid, row[0]);
+
 
 		trigger_tag = (zbx_dc_trigger_tag_t *)DCfind_id(&config->trigger_tags, triggertagid, sizeof(zbx_dc_trigger_tag_t), &found);
 		DCstrpool_replace(found, &trigger_tag->tag, row[2]);
diff --git a/src/libs/zbxdbcache/dbsync.c b/src/libs/zbxdbcache/dbsync.c
index 939e5f22d5..3093ee8cc7 100644
--- a/src/libs/zbxdbcache/dbsync.c
+++ b/src/libs/zbxdbcache/dbsync.c
@@ -2157,12 +2157,12 @@ int	zbx_dbsync_compare_triggers(zbx_dbsync_t *sync)
 	DB_RESULT		result;
 	zbx_hashset_t		ids;
 	zbx_hashset_iter_t	iter;
-	zbx_uint64_t		rowid;
+	zbx_uint64_t		rowid, last_rowid = 0;
 	ZBX_DC_TRIGGER		*trigger;
 	char			**row;
 
 	if (NULL == (result = DBselect(
-			"select distinct t.triggerid,t.description,t.expression,t.error,t.priority,t.type,t.value,"
+			"select t.triggerid,t.description,t.expression,t.error,t.priority,t.type,t.value,"
 				"t.state,t.lastchange,t.status,t.recovery_mode,t.recovery_expression,"
 				"t.correlation_mode,t.correlation_tag,opdata"
 			" from hosts h,items i,functions f,triggers t"
@@ -2170,7 +2170,8 @@ int	zbx_dbsync_compare_triggers(zbx_dbsync_t *sync)
 				" and i.itemid=f.itemid"
 				" and f.triggerid=t.triggerid"
 				" and h.status in (%d,%d)"
-				" and t.flags<>%d",
+				" and t.flags<>%d"
+				" order by t.triggerid",
 			HOST_STATUS_MONITORED, HOST_STATUS_NOT_MONITORED,
 			ZBX_FLAG_DISCOVERY_PROTOTYPE)))
 	{
@@ -2191,6 +2192,12 @@ int	zbx_dbsync_compare_triggers(zbx_dbsync_t *sync)
 	while (NULL != (dbrow = DBfetch(result)))
 	{
 		ZBX_STR2UINT64(rowid, dbrow[0]);
+
+		if (rowid == last_rowid)
+			continue;
+
+		last_rowid = rowid;
+
 		zbx_hashset_insert(&ids, &rowid, sizeof(rowid));
 
 		row = dbsync_preproc_row(sync, dbrow);
@@ -2901,18 +2908,19 @@ int	zbx_dbsync_compare_trigger_tags(zbx_dbsync_t *sync)
 	DB_RESULT		result;
 	zbx_hashset_t		ids;
 	zbx_hashset_iter_t	iter;
-	zbx_uint64_t		rowid;
+	zbx_uint64_t		rowid, last_rowid = 0;
 	zbx_dc_trigger_tag_t	*trigger_tag;
 
 	if (NULL == (result = DBselect(
-			"select distinct tt.triggertagid,tt.triggerid,tt.tag,tt.value"
+			"select tt.triggertagid,tt.triggerid,tt.tag,tt.value"
 			" from trigger_tag tt,triggers t,hosts h,items i,functions f"
 			" where t.triggerid=tt.triggerid"
 				" and t.flags<>%d"
 				" and h.hostid=i.hostid"
 				" and i.itemid=f.itemid"
 				" and f.triggerid=tt.triggerid"
-				" and h.status in (%d,%d)",
+				" and h.status in (%d,%d)"
+			" order by tt.triggertagid",
 				ZBX_FLAG_DISCOVERY_PROTOTYPE, HOST_STATUS_MONITORED, HOST_STATUS_NOT_MONITORED)))
 	{
 		return FAIL;
@@ -2934,6 +2942,12 @@ int	zbx_dbsync_compare_trigger_tags(zbx_dbsync_t *sync)
 		unsigned char	tag = ZBX_DBSYNC_ROW_NONE;
 
 		ZBX_STR2UINT64(rowid, dbrow[0]);
+
+		if (rowid == last_rowid)
+			continue;
+
+		last_rowid = rowid;
+
 		zbx_hashset_insert(&ids, &rowid, sizeof(rowid));
 
 		if (NULL == (trigger_tag = (zbx_dc_trigger_tag_t *)zbx_hashset_search(&dbsync_env.cache->trigger_tags,
