ORA-01795 when querying with .Contains on large lists

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Thomasdc
Posts: 12
Joined: Sat 07 Jul 2018 14:20

ORA-01795 when querying with .Contains on large lists

Post by Thomasdc » Tue 03 Mar 2020 13:06

Framework: Entity Framework Core 3.1
Provider: Devart.Data.Oracle.EFCore 9.11.951
Issue:

The following LINQ query worked fine in Devart.Data.Oracle.EFCore 9.7.805 (Entity Framework Core 2.2):

Code: Select all

var ids = Enumerable.Range(0, 10000).ToArray();
dbContext.Set<Person>().Where(person => ids.Contains(person.Id)).ToListAsync();
Since Oracle only allows max 1000 expressions in a list, it nicely split the query:

Code: Select all

SELECT "_".ID,
       ...
FROM   PERSON "_"
WHERE  "_".ID IN (0, 1, 2, ... 999) 
		OR "_".ID IN (1000, 1001, 1002, ... 1999) 
		OR "_".ID IN (2000, 2001, 2002, ... 2999) 
		...
However, version 9.11.951 generates the following query, resulting in a ORA-01795: maximum number of expressions in a list is 1000

Code: Select all

SELECT "_".ID,
       ...
FROM   PERSON "_"
WHERE  "_".ID IN (0, 1, 2, ... 9999)

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: ORA-01795 when querying with .Contains on large lists

Post by Shalex » Sat 07 Mar 2020 15:39

Thank you for your report. We have reproduced the issue with EF Core 3.1.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: ORA-01795 when querying with .Contains on large lists

Post by Shalex » Sat 04 Apr 2020 13:47

The bug with using collections with more than 1000 items in a .Contains() method in EF Core 3 is fixed in v9.11.980: viewtopic.php?f=1&t=40466.

Post Reply