diff --git a/src/zabbix_server/proxyconfigread/proxyconfig_read.c b/src/zabbix_server/proxyconfigread/proxyconfig_read.c
index 1b3b7d37797..bfa8f4f58ba 100644
--- a/src/zabbix_server/proxyconfigread/proxyconfig_read.c
+++ b/src/zabbix_server/proxyconfigread/proxyconfig_read.c
@@ -181,14 +181,14 @@ static void	proxyconfig_add_row(struct zbx_json *j, const DB_ROW row, const ZBX_
  *             j          - [OUT] the output json                             *
  *                                                                            *
  ******************************************************************************/
-static void	proxyconfig_get_fields(char **sql, size_t *sql_alloc, size_t *sql_offset, const ZBX_TABLE *table,
-		struct zbx_json *j)
+static void	proxyconfig_get_fields(char **sql, size_t *sql_alloc, size_t *sql_offset, const ZBX_TABLE *table, 
+		const char *alias, struct zbx_json *j)
 {
 	int	i;
 
 	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
 
-	zbx_snprintf_alloc(sql, sql_alloc, sql_offset, "select %s", table->recid);
+	zbx_snprintf_alloc(sql, sql_alloc, sql_offset, "select %s%s", alias, table->recid);
 
 	zbx_json_addarray(j, "fields");
 	zbx_json_addstring(j, NULL, table->recid, ZBX_JSON_TYPE_STRING);
@@ -199,6 +199,8 @@ static void	proxyconfig_get_fields(char **sql, size_t *sql_alloc, size_t *sql_of
 			continue;
 
 		zbx_chrcpy_alloc(sql, sql_alloc, sql_offset, ',');
+		zbx_strcpy_alloc(sql, sql_alloc, sql_offset, alias);
+		
 		zbx_strcpy_alloc(sql, sql_alloc, sql_offset, table->fields[i].name);
 
 		zbx_json_addstring(j, NULL, table->fields[i].name, ZBX_JSON_TYPE_STRING);
@@ -242,7 +244,7 @@ static int	proxyconfig_get_macro_updates(const char *table_name, const zbx_vecto
 
 	sql = (char *)zbx_malloc(NULL, sql_alloc);
 
-	proxyconfig_get_fields(&sql, &sql_alloc, &sql_offset, table, j);
+	proxyconfig_get_fields(&sql, &sql_alloc, &sql_offset, table, "", j);
 	zbx_json_addarray(j, "data");
 
 	zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, " from %s", table->table);
@@ -364,8 +366,9 @@ out:
  *               FAIL    - otherwise                                          *
  *                                                                            *
  ******************************************************************************/
-static int	proxyconfig_get_table_data(const char *table_name, const char *key_name,
-		const zbx_vector_uint64_t *key_ids, const char *filter, zbx_vector_uint64_t *recids, struct zbx_json *j,
+static int	proxyconfig_get_table_data_ext(const char *table_name, const char *key_name,
+		const zbx_vector_uint64_t *key_ids, const char *filter, zbx_vector_uint64_t *recids,
+		const char *join, const zbx_hashset_t *key_ids_filter, struct zbx_json *j, 
 		char **error)
 {
 	DB_RESULT	result;
@@ -374,20 +377,35 @@ static int	proxyconfig_get_table_data(const char *table_name, const char *key_na
 	char		*sql = NULL;
 	size_t		sql_alloc =  4 * ZBX_KIBIBYTE, sql_offset = 0;
 	int		ret = FAIL;
+	char		*alias, *alias_from;
 
-	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
+	zabbix_log(LOG_LEVEL_DEBUG, "In %s() %s", __func__, table_name);
+
+	if (NULL != join)
+	{
+		alias = "t.";
+		alias_from = " t";
+	}
+	else
+	{
+		alias = "";
+		alias_from = "";	
+	}
 
 	table = zbx_db_get_table(table_name);
 	zbx_json_addobject(j, table->table);
 
 	sql = (char *)zbx_malloc(NULL, sql_alloc);
-	proxyconfig_get_fields(&sql, &sql_alloc, &sql_offset, table, j);
+	proxyconfig_get_fields(&sql, &sql_alloc, &sql_offset, table, alias, j);
 
 	zbx_json_addarray(j, ZBX_PROTO_TAG_DATA);
 
-	if (NULL == key_ids || 0 != key_ids->values_num)
+	if ((NULL == key_ids || 0 != key_ids->values_num) && (NULL == key_ids_filter || 0 != key_ids_filter->num_data))
 	{
-		zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, " from %s", table->table);
+		zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, " from %s%s", table->table, alias_from);
+
+		if (NULL != join)
+			zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset, join);
 
 		if (NULL != key_ids || NULL != filter)
 		{
@@ -409,6 +427,7 @@ static int	proxyconfig_get_table_data(const char *table_name, const char *key_na
 		}
 
 		zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset, " order by ");
+		zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset, alias);
 		zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset, table->recid);
 
 		if (NULL == (result = zbx_db_select("%s", sql)))
@@ -421,6 +440,13 @@ static int	proxyconfig_get_table_data(const char *table_name, const char *key_na
 
 		while (NULL != (row = zbx_db_fetch(result)))
 		{
+			zbx_uint64_t	recid;
+	
+			ZBX_STR2UINT64(recid, row[0]);
+
+			if (NULL != key_ids_filter && NULL == zbx_hashset_search(key_ids_filter, &recid))
+				continue;
+
 			zbx_json_addarray(j, NULL);
 			proxyconfig_add_row(j, row, table, recids);
 			zbx_json_close(j);
@@ -443,6 +469,13 @@ out:
 	return ret;
 }
 
+static int	proxyconfig_get_table_data(const char *table_name, const char *key_name,
+		const zbx_vector_uint64_t *key_ids, const char *filter, zbx_vector_uint64_t *recids,
+		struct zbx_json *j, char **error)
+{
+	return proxyconfig_get_table_data_ext(table_name, key_name, key_ids, filter, recids, NULL, NULL, j, error);
+}
+
 typedef struct
 {
 	zbx_uint64_t	itemid;
@@ -503,7 +536,7 @@ static zbx_proxyconfig_dep_item_t	*proxyconfig_dep_item_create(zbx_uint64_t item
  *                                                                            *
  ******************************************************************************/
 static int	proxyconfig_get_item_data(const zbx_vector_uint64_t *hostids, zbx_vector_uint64_t *itemids,
-		struct zbx_json *j, char **error)
+		zbx_hashset_t *items, struct zbx_json *j, char **error)
 {
 	DB_RESULT	result;
 	DB_ROW		row;
@@ -514,12 +547,10 @@ static int	proxyconfig_get_item_data(const zbx_vector_uint64_t *hostids, zbx_vec
 	zbx_uint64_t	itemid, master_itemid;
 
 	zbx_vector_proxyconfig_dep_item_ptr_t	dep_items;
-	zbx_hashset_t				items;
 	zbx_proxyconfig_dep_item_t		*dep_item;
 
 	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
 
-	zbx_hashset_create(&items, 1000, ZBX_DEFAULT_UINT64_HASH_FUNC, ZBX_DEFAULT_UINT64_COMPARE_FUNC);
 	zbx_vector_proxyconfig_dep_item_ptr_create(&dep_items);
 
 	table = zbx_db_get_table("items");
@@ -548,7 +579,7 @@ static int	proxyconfig_get_item_data(const zbx_vector_uint64_t *hostids, zbx_vec
 	zbx_json_addobject(j, table->table);
 
 	sql = (char *)zbx_malloc(NULL, sql_alloc);
-	proxyconfig_get_fields(&sql, &sql_alloc, &sql_offset, table, j);
+	proxyconfig_get_fields(&sql, &sql_alloc, &sql_offset, table, "", j);
 
 	zbx_json_addarray(j, ZBX_PROTO_TAG_DATA);
 
@@ -583,7 +614,7 @@ static int	proxyconfig_get_item_data(const zbx_vector_uint64_t *hostids, zbx_vec
 				proxyconfig_add_row(j, row, table, itemids);
 				zbx_json_close(j);
 
-				zbx_hashset_insert(&items, &itemid, sizeof(itemid));
+				zbx_hashset_insert(items, &itemid, sizeof(itemid));
 			}
 			else
 			{
@@ -605,13 +636,13 @@ static int	proxyconfig_get_item_data(const zbx_vector_uint64_t *hostids, zbx_vec
 				{
 					dep_item = dep_items.values[i];
 
-					if (NULL != zbx_hashset_search(&items, &dep_item->master_itemid))
+					if (NULL != zbx_hashset_search(items, &dep_item->master_itemid))
 					{
 						zbx_json_addarray(j, NULL);
 						proxyconfig_add_row(j, dep_item->row, table, itemids);
 						zbx_json_close(j);
 
-						zbx_hashset_insert(&items, &dep_item->itemid, sizeof(zbx_uint64_t));
+						zbx_hashset_insert(items, &dep_item->itemid, sizeof(zbx_uint64_t));
 						proxyconfig_dep_item_free(dep_item);
 						zbx_vector_proxyconfig_dep_item_ptr_remove_noorder(&dep_items, i);
 					}
@@ -634,7 +665,6 @@ out:
 
 	zbx_vector_proxyconfig_dep_item_ptr_clear_ext(&dep_items, proxyconfig_dep_item_free);
 	zbx_vector_proxyconfig_dep_item_ptr_destroy(&dep_items);
-	zbx_hashset_destroy(&items);
 
 	zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
 
@@ -657,11 +687,15 @@ static int	proxyconfig_get_host_data(const zbx_vector_uint64_t *hostids, struct
 {
 	zbx_vector_uint64_t	interfaceids, itemids;
 	int			ret = FAIL;
+	char			*sql = NULL;
+	size_t			sql_alloc =  0, sql_offset = 0;
+	zbx_hashset_t		items;
 
 	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
 
 	zbx_vector_uint64_create(&interfaceids);
 	zbx_vector_uint64_create(&itemids);
+	zbx_hashset_create(&items, 1000, ZBX_DEFAULT_UINT64_HASH_FUNC, ZBX_DEFAULT_UINT64_COMPARE_FUNC);
 
 	if (SUCCEED != proxyconfig_get_table_data("hosts", "hostid", hostids, NULL, NULL, j, error))
 		goto out;
@@ -678,11 +712,22 @@ static int	proxyconfig_get_host_data(const zbx_vector_uint64_t *hostids, struct
 	if (SUCCEED != proxyconfig_get_table_data("host_inventory", "hostid", hostids, NULL, NULL, j, error))
 		goto out;
 
-	if (SUCCEED != proxyconfig_get_item_data(hostids, &itemids, j, error))
+	if (SUCCEED != proxyconfig_get_item_data(hostids, &itemids, &items, j, error))
 		goto out;
 
-	if (SUCCEED != proxyconfig_get_table_data("item_rtdata", "itemid", &itemids, NULL, NULL, j, error))
+	
+	if (0 != hostids->values_num)
+	{
+		zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset, " join items i on i.itemid=t.itemid and ");
+		zbx_db_add_condition_alloc(&sql, &sql_alloc, &sql_offset, "i.hostid", hostids->values,
+				hostids->values_num);
+	}
+
+	if (SUCCEED != proxyconfig_get_table_data_ext("item_rtdata", NULL, NULL, NULL, NULL, sql, &items, j,
+			error))
+	{
 		goto out;
+	}
 
 	if (SUCCEED != proxyconfig_get_table_data("item_preproc", "itemid", &itemids, NULL, NULL, j, error))
 		goto out;
@@ -694,6 +739,8 @@ static int	proxyconfig_get_host_data(const zbx_vector_uint64_t *hostids, struct
 out:
 	zbx_vector_uint64_destroy(&itemids);
 	zbx_vector_uint64_destroy(&interfaceids);
+	zbx_hashset_destroy(&items);
+	zbx_free(sql);
 
 	zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
 
