diff --git a/include/db.h b/include/db.h
index 137c234d10f..a59cf7a10ad 100644
--- a/include/db.h
+++ b/include/db.h
@@ -601,6 +601,8 @@ void	zbx_destroy_itservices_lock(void);
 
 void	DBadd_condition_alloc(char **sql, size_t *sql_alloc, size_t *sql_offset, const char *fieldname,
 		const zbx_uint64_t *values, const int num);
+void	DBadd_condition_alloc_ext(char **sql, size_t *sql_alloc, size_t *sql_offset, const char *fieldname,
+		const zbx_uint64_t *values, const int num, int min_num_between);
 void	DBadd_str_condition_alloc(char **sql, size_t *sql_alloc, size_t *sql_offset, const char *fieldname,
 		const char **values, const int num);
 
diff --git a/src/libs/zbxdbcache/dbcache.c b/src/libs/zbxdbcache/dbcache.c
index e3a5cec131a..7bba35ac87a 100644
--- a/src/libs/zbxdbcache/dbcache.c
+++ b/src/libs/zbxdbcache/dbcache.c
@@ -471,7 +471,8 @@ static void	dc_remove_updated_trends(ZBX_DC_TREND *trends, int trends_num, const
 		if (0 < j)
 			zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, " clock<%d and", clocks[j - 1]);
 
-		DBadd_condition_alloc(&sql, &sql_alloc, &sql_offset, "itemid", itemids, *itemids_num);
+		/* avoid between if already selecting only up to 1000 values */
+		DBadd_condition_alloc_ext(&sql, &sql_alloc, &sql_offset, "itemid", itemids, *itemids_num, ZBX_HC_SYNC_MAX);
 
 		result = DBselect("%s", sql);
 
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index a4ed65b73cc..409d3eb3ade 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -955,8 +955,6 @@ int	zbx_tsdb_table_has_compressed_chunks(const char *table_names)
 #endif
 
 #ifdef HAVE_ORACLE
-#define MIN_NUM_BETWEEN	5	/* minimum number of consecutive values for using "between <id1> and <idN>" */
-
 /******************************************************************************
  *                                                                            *
  * Function: DBadd_condition_alloc_btw                                        *
@@ -979,7 +977,8 @@ int	zbx_tsdb_table_has_compressed_chunks(const char *table_names)
  *                                                                            *
  ******************************************************************************/
 static void	DBadd_condition_alloc_btw(char **sql, size_t *sql_alloc, size_t *sql_offset, const char *fieldname,
-		const zbx_uint64_t *values, const int num, int **seq_len, int *seq_num, int *in_num, int *between_num)
+		const zbx_uint64_t *values, const int num, int **seq_len, int *seq_num, int *in_num, int *between_num,
+		int min_num_between)
 {
 	int		i, len, first, start;
 	zbx_uint64_t	value;
@@ -992,7 +991,7 @@ static void	DBadd_condition_alloc_btw(char **sql, size_t *sql_alloc, size_t *sql
 	{
 		if (values[i] != ++value)
 		{
-			if (MIN_NUM_BETWEEN <= len)
+			if (min_num_between <= len)
 				(*between_num)++;
 			else
 				*in_num += len;
@@ -1005,7 +1004,7 @@ static void	DBadd_condition_alloc_btw(char **sql, size_t *sql_alloc, size_t *sql
 			len++;
 	}
 
-	if (MIN_NUM_BETWEEN <= len)
+	if (min_num_between <= len)
 		(*between_num)++;
 	else
 		*in_num += len;
@@ -1018,7 +1017,7 @@ static void	DBadd_condition_alloc_btw(char **sql, size_t *sql_alloc, size_t *sql
 	/* compose "between"s */
 	for (i = 0, first = 1, start = 0; i < *seq_num; i++)
 	{
-		if (MIN_NUM_BETWEEN <= (*seq_len)[i])
+		if (min_num_between <= (*seq_len)[i])
 		{
 			if (1 != first)
 			{
@@ -1040,7 +1039,6 @@ static void	DBadd_condition_alloc_btw(char **sql, size_t *sql_alloc, size_t *sql
 	}
 }
 #endif
-
 /******************************************************************************
  *                                                                            *
  * Function: DBadd_condition_alloc                                            *
@@ -1059,8 +1057,8 @@ static void	DBadd_condition_alloc_btw(char **sql, size_t *sql_alloc, size_t *sql
  *             num        - [IN] number of elements in 'values' array         *
  *                                                                            *
  ******************************************************************************/
-void	DBadd_condition_alloc(char **sql, size_t *sql_alloc, size_t *sql_offset, const char *fieldname,
-		const zbx_uint64_t *values, const int num)
+void	DBadd_condition_alloc_ext(char **sql, size_t *sql_alloc, size_t *sql_offset, const char *fieldname,
+		const zbx_uint64_t *values, const int num, int min_num_between)
 {
 #ifdef HAVE_ORACLE
 	int		start, between_num = 0, in_num = 0, seq_num;
@@ -1076,7 +1074,7 @@ void	DBadd_condition_alloc(char **sql, size_t *sql_alloc, size_t *sql_offset, co
 	zbx_chrcpy_alloc(sql, sql_alloc, sql_offset, ' ');
 #ifdef HAVE_ORACLE
 	DBadd_condition_alloc_btw(sql, sql_alloc, sql_offset, fieldname, values, num, &seq_len, &seq_num, &in_num,
-			&between_num);
+			&between_num, min_num_between);
 
 	if (1 < in_num)
 		zbx_snprintf_alloc(sql, sql_alloc, sql_offset, "%s in (", fieldname);
@@ -1084,7 +1082,7 @@ void	DBadd_condition_alloc(char **sql, size_t *sql_alloc, size_t *sql_offset, co
 	/* compose "in"s */
 	for (i = 0, in_cnt = 0, start = 0; i < seq_num; i++)
 	{
-		if (MIN_NUM_BETWEEN > seq_len[i])
+		if (min_num_between > seq_len[i])
 		{
 			if (1 == in_num)
 #else
@@ -1181,9 +1179,15 @@ void	DBadd_condition_alloc(char **sql, size_t *sql_alloc, size_t *sql_offset, co
 		zbx_chrcpy_alloc(sql, sql_alloc, sql_offset, ')');
 
 #undef MAX_EXPRESSIONS
-#ifdef HAVE_ORACLE
+
+}
+
+void	DBadd_condition_alloc(char **sql, size_t *sql_alloc, size_t *sql_offset, const char *fieldname,
+		const zbx_uint64_t *values, const int num)
+{
+#define MIN_NUM_BETWEEN	5	/* minimum number of consecutive values for using "between <id1> and <idN>" */
+	DBadd_condition_alloc_ext(sql, sql_alloc, sql_offset, fieldname, values, num, MIN_NUM_BETWEEN);
 #undef MIN_NUM_BETWEEN
-#endif
 }
 
 /******************************************************************************
