Skip to content

pgsql数据库查询返回54011 ROW expressions can have at most 1664 entries #1972

Closed
@peng951

Description

@peng951

问题描述及重现代码:

// c# code
//先定义一个部门列表
public class Department
{
        /// <summary>
        /// 组织架构Id
        /// </summary>
        [Column(IsPrimary  = true)]
        public int DepartmentId { get; set; }
      
}

//代码查询部分
public void action(object parama)
{
            var depList = new List<int>();
            for (int i = 0; i < 50000; i++)
            {
                depList.Add(i);
            }
            var depselect = await  _freesql.Select<Department>()
                .WhereIf(true, x => depList != null && depList.Contains(x.DepartmentId))
                .ToListAsync();
}
调上面这个方法返回"54011: ROW expressions can have at most 1664 entries\r\n\r\nPOSITION: 265"
看一下翻译过来的sql,大概意思是
select * from department a where (0,1,2,......4999) is not null and a.departmentid in (0,1,2,......4999)导致数据库层面报54011

![Image](https://github.com/user-attachments/assets/3995689d-32a7-48cf-ad1f-8211883b1bb8)

#### 数据库版本
pg13

#### 安装的Nuget包
3.2.680

#### .net framework/. net core? 及具体版本
net8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions