一、在Mysql中配置参数eq_range_index_dive_limit用于限制索引分析方式,默认值为200。

  • 查询limit大小
    SHOW GLOBAL VARIABLES LIKE 'eq_range_index_dive_limit';	

二、当in入参过多时可以拆分入参,分批查询。

List<Long> idList= deviceMapper.getAllId();

int batchSize = 1000; // 每个批次的大小
int listSize = idList.size();

for (int i = 0; i < listSize; i += batchSize) {
	List<Long> batch = idList.subList(i, Math.min(i + batchSize, listSize));
	
	// 对batch进行处理
	EntityWrapper<Device> deviceEntityWrapper = new EntityWrapper<>();
	deviceEntityWrapper.in(Device.COLUMN_ID, batch);
    
   //使用in关键字批量查询list
	List<Device> tempList = deviceHandler.selectEntities(deviceEntityWrapper);
}