diff --git a/src/libs/zbxcacheconfig/dbconfig_maintenance.c b/src/libs/zbxcacheconfig/dbconfig_maintenance.c
index cfbf215d1d9..6463aa2c247 100644
--- a/src/libs/zbxcacheconfig/dbconfig_maintenance.c
+++ b/src/libs/zbxcacheconfig/dbconfig_maintenance.c
@@ -25,6 +25,7 @@
 #include "zbxalgo.h"
 #include "zbxnum.h"
 #include "zbxtime.h"
+#include "zbxtypes.h"
 
 typedef struct
 {
@@ -973,7 +974,8 @@ static void	dc_get_host_maintenances_by_ids(const zbx_vector_uint64_t *maintenan
 	zbx_dc_maintenance_t	*maintenance;
 	int			i, j;
 	zbx_vector_uint64_t	groupids;
-
+	zbx_prof_start(__func__, ZBX_PROF_PROCESSING);
+	
 	zbx_vector_uint64_create(&groupids);
 
 	for (i = 0; i < maintenanceids->values_num; i++)
@@ -1019,6 +1021,7 @@ static void	dc_get_host_maintenances_by_ids(const zbx_vector_uint64_t *maintenan
 	}
 
 	zbx_vector_uint64_destroy(&groupids);
+	zbx_prof_end();
 }
 
 /******************************************************************************
@@ -1409,7 +1412,6 @@ int	zbx_dc_get_event_maintenances(zbx_vector_ptr_t *event_queries, const zbx_vec
 	int				i, j, k, ret = FAIL;
 	zbx_event_suppress_query_t	*query;
 	ZBX_DC_ITEM			*item;
-	ZBX_DC_FUNCTION			*function;
 	zbx_vector_uint64_t		hostids;
 	zbx_hashset_iter_t		iter;
 	zbx_host_event_maintenance_t	*host_event_maintenance;
@@ -1453,59 +1455,54 @@ int	zbx_dc_get_event_maintenances(zbx_vector_ptr_t *event_queries, const zbx_vec
 
 		/* Some processes do not have trigger data at hand and create event queries */
 		/* without filling query functionids. Do it here if necessary.              */
+		zbx_prof_start("query", ZBX_PROF_PROCESSING);
+
 		if (0 == query->functionids.values_num)
 		{
 			ZBX_DC_TRIGGER	*trigger;
-
+			zbx_uint64_t	*itemid;
+			
 			if (NULL == (trigger = (ZBX_DC_TRIGGER *)zbx_hashset_search(&config->triggers,
 					&query->triggerid)))
 			{
+				zbx_prof_end();
 				continue;
 			}
 
-			if (ZBX_FLAG_DISCOVERY_PROTOTYPE == trigger->flags)
+			if (ZBX_FLAG_DISCOVERY_PROTOTYPE == trigger->flags || NULL == trigger->itemids)
 			{
 				zabbix_log(LOG_LEVEL_CRIT, "cannot process event for trigger prototype"
 						" (triggerid:" ZBX_FS_UI64 ")", trigger->triggerid);
 				THIS_SHOULD_NEVER_HAPPEN;
+				zbx_prof_end();
 				continue;
 			}
-
-			zbx_get_serialized_expression_functionids(trigger->expression, trigger->expression_bin,
-					&query->functionids);
-
-			if (TRIGGER_RECOVERY_MODE_RECOVERY_EXPRESSION == trigger->recovery_mode)
-			{
-				zbx_get_serialized_expression_functionids(trigger->recovery_expression,
-						trigger->recovery_expression_bin, &query->functionids);
-			}
-		}
-
-		for (j = 0; j < query->functionids.values_num; j++)
-		{
-			ZBX_DC_HOST	*dc_host;
-
-			if (NULL == (function = (ZBX_DC_FUNCTION *)zbx_hashset_search(&config->functions,
-					&query->functionids.values[j])))
+			
+			for (itemid = trigger->itemids; 0 != *itemid; itemid++)
 			{
-				continue;
-			}
+				ZBX_DC_HOST	*dc_host;
 
-			if (NULL == (item = (ZBX_DC_ITEM *)zbx_hashset_search(&config->items, &function->itemid)))
-				continue;
+				if (NULL == (item = (ZBX_DC_ITEM *)zbx_hashset_search(&config->items, itemid)))
+					continue;
 
-			if (NULL == (dc_host = (ZBX_DC_HOST *)zbx_hashset_search(&config->hosts, &item->hostid)))
-				continue;
+				if (NULL == (dc_host = (ZBX_DC_HOST *)zbx_hashset_search(&config->hosts, &item->hostid)))
+					continue;
 
-			if (HOST_MAINTENANCE_STATUS_OFF == dc_host->maintenance_status)
-				goto skip;
+				if (HOST_MAINTENANCE_STATUS_OFF == dc_host->maintenance_status)
+				{
+					zbx_prof_end();
+					goto skip;
+				}
 
-			zbx_vector_uint64_append(&hostids, item->hostid);
+				zbx_vector_uint64_append(&hostids, item->hostid);
+			}
 		}
+		zbx_prof_end();
 
 		zbx_vector_uint64_sort(&hostids, ZBX_DEFAULT_UINT64_COMPARE_FUNC);
 		zbx_vector_uint64_uniq(&hostids, ZBX_DEFAULT_UINT64_COMPARE_FUNC);
 
+		zbx_prof_start("find matching maintenances", ZBX_PROF_PROCESSING);
 		/* find matching maintenances */
 		for (j = 0; j < hostids.values_num; j++)
 		{
@@ -1542,6 +1539,7 @@ int	zbx_dc_get_event_maintenances(zbx_vector_ptr_t *event_queries, const zbx_vec
 				ret = SUCCEED;
 			}
 		}
+		zbx_prof_end();
 skip:
 		zbx_vector_uint64_clear(&hostids);
 	}
