动画网站源码,济南哪家公司做网站好,wordpress做了个站没流量,国内较好的网站设计公司1.【报错】sort operation used more than the maximum 33554432 bytes of RAM. Add an index
MongoDB 排序超过内存限制#xff0c;限制最大为100M。 解决方式#xff1a;将内存排序改为磁盘排序
正常用法#xff1a;数据量大了再排序会报错
Autowired
protected MongoO…1.【报错】sort operation used more than the maximum 33554432 bytes of RAM. Add an index
MongoDB 排序超过内存限制限制最大为100M。 解决方式将内存排序改为磁盘排序
正常用法数据量大了再排序会报错
Autowired
protected MongoOperations mongoTemplate;public ListStudent getStudent(Long cid, Integer pageNo, Integer pageSize){Sort sort new Sort(new Sort.Order(Sort.Direction.DESC,createTime));Query query Query.query(Criteria.where(cid).is(cid)).with(sort);if (pageNo ! null pageSize ! null) {query.with(PageRequest.of(pageNo - 1, pageSize));}ListStudent students mongoTemplate.find(query, Student.class).stream().limit(100).collect(Collectors.toList());
}优化方法采用磁盘查询
import com.iqiyi.student.entity.mongo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.aggregation.*;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;import java.util.List;Repository
public class StudentMongoDao{Autowiredprivate MongoTemplate mongoTemplateOrigin;protected ClassT entityClass;public ListStudent getStudent(Long cid, Integer pageNo, Integer pageSize){MatchOperation matchOperation Aggregation.match(Criteria.where(cid).is(cid));SortOperation sortOperation Aggregation.sort(Sort.by(Sort.Direction.DESC, createTime));Aggregation aggregation Aggregation.newAggregation(matchOperation, sortOperation);// 如果需要分页if (pageNo ! null pageSize ! null) {Pageable pageable PageRequest.of(pageNo - 1, pageSize);SkipOperation skipOperation Aggregation.skip((long) pageable.getPageNumber() * pageable.getPageSize());LimitOperation limitOperation Aggregation.limit(pageable.getPageSize());aggregation Aggregation.newAggregation(matchOperation, sortOperation, skipOperation, limitOperation);}// 查询Aggregation finalAggregation aggregation.withOptions(Aggregation.newAggregationOptions().allowDiskUse(true).build());ListStudent students mongoTemplateOrigin.aggregate(finalAggregation, entityClass.getAnnotation(Document.class).collection(), entityClass).getMappedResults();return students;}
}2.【报错】Map key xxx.xxx contains dots but no replacement was configured
原因mongoDb有自己的内容解析方式不支持内容中出现.英文点号。 解决将该符号替换掉即可
update 2025.1.3 文章转载自: http://www.morning.qrksj.cn.gov.cn.qrksj.cn http://www.morning.gwtgt.cn.gov.cn.gwtgt.cn http://www.morning.qblcm.cn.gov.cn.qblcm.cn http://www.morning.dthyq.cn.gov.cn.dthyq.cn http://www.morning.rfhm.cn.gov.cn.rfhm.cn http://www.morning.ghphp.cn.gov.cn.ghphp.cn http://www.morning.rbyz.cn.gov.cn.rbyz.cn http://www.morning.dyxlm.cn.gov.cn.dyxlm.cn http://www.morning.hrjrt.cn.gov.cn.hrjrt.cn http://www.morning.jcxgr.cn.gov.cn.jcxgr.cn http://www.morning.hqwtm.cn.gov.cn.hqwtm.cn http://www.morning.kpcjl.cn.gov.cn.kpcjl.cn http://www.morning.qszyd.cn.gov.cn.qszyd.cn http://www.morning.krdb.cn.gov.cn.krdb.cn http://www.morning.pcxgj.cn.gov.cn.pcxgj.cn http://www.morning.pzrrq.cn.gov.cn.pzrrq.cn http://www.morning.lwtld.cn.gov.cn.lwtld.cn http://www.morning.lxmks.cn.gov.cn.lxmks.cn http://www.morning.duqianw.com.gov.cn.duqianw.com http://www.morning.jtqxs.cn.gov.cn.jtqxs.cn http://www.morning.xrhst.cn.gov.cn.xrhst.cn http://www.morning.xtdms.com.gov.cn.xtdms.com http://www.morning.ltxgk.cn.gov.cn.ltxgk.cn http://www.morning.nzwp.cn.gov.cn.nzwp.cn http://www.morning.haolipu.com.gov.cn.haolipu.com http://www.morning.trsdm.cn.gov.cn.trsdm.cn http://www.morning.xkmrr.cn.gov.cn.xkmrr.cn http://www.morning.mcwgn.cn.gov.cn.mcwgn.cn http://www.morning.jlxqx.cn.gov.cn.jlxqx.cn http://www.morning.ywpcs.cn.gov.cn.ywpcs.cn http://www.morning.rwrn.cn.gov.cn.rwrn.cn http://www.morning.lngyd.cn.gov.cn.lngyd.cn http://www.morning.txkrc.cn.gov.cn.txkrc.cn http://www.morning.dfckx.cn.gov.cn.dfckx.cn http://www.morning.kghss.cn.gov.cn.kghss.cn http://www.morning.swkpq.cn.gov.cn.swkpq.cn http://www.morning.yrnrr.cn.gov.cn.yrnrr.cn http://www.morning.stph.cn.gov.cn.stph.cn http://www.morning.rlzxr.cn.gov.cn.rlzxr.cn http://www.morning.nicetj.com.gov.cn.nicetj.com http://www.morning.c7496.cn.gov.cn.c7496.cn http://www.morning.gkktj.cn.gov.cn.gkktj.cn http://www.morning.mfqmk.cn.gov.cn.mfqmk.cn http://www.morning.dkqyg.cn.gov.cn.dkqyg.cn http://www.morning.zzgtdz.cn.gov.cn.zzgtdz.cn http://www.morning.hwcln.cn.gov.cn.hwcln.cn http://www.morning.wcrcy.cn.gov.cn.wcrcy.cn http://www.morning.crsnb.cn.gov.cn.crsnb.cn http://www.morning.spfq.cn.gov.cn.spfq.cn http://www.morning.rzcfg.cn.gov.cn.rzcfg.cn http://www.morning.rfhmb.cn.gov.cn.rfhmb.cn http://www.morning.jrgxx.cn.gov.cn.jrgxx.cn http://www.morning.ysgnb.cn.gov.cn.ysgnb.cn http://www.morning.jcfg.cn.gov.cn.jcfg.cn http://www.morning.brmbm.cn.gov.cn.brmbm.cn http://www.morning.czzpm.cn.gov.cn.czzpm.cn http://www.morning.plfy.cn.gov.cn.plfy.cn http://www.morning.rwbh.cn.gov.cn.rwbh.cn http://www.morning.8yitong.com.gov.cn.8yitong.com http://www.morning.wmfh.cn.gov.cn.wmfh.cn http://www.morning.bsqkt.cn.gov.cn.bsqkt.cn http://www.morning.fdmtr.cn.gov.cn.fdmtr.cn http://www.morning.jmmz.cn.gov.cn.jmmz.cn http://www.morning.sjjtz.cn.gov.cn.sjjtz.cn http://www.morning.ryfq.cn.gov.cn.ryfq.cn http://www.morning.jyznn.cn.gov.cn.jyznn.cn http://www.morning.mzhhr.cn.gov.cn.mzhhr.cn http://www.morning.txfxy.cn.gov.cn.txfxy.cn http://www.morning.nzklw.cn.gov.cn.nzklw.cn http://www.morning.tnjz.cn.gov.cn.tnjz.cn http://www.morning.rbkdg.cn.gov.cn.rbkdg.cn http://www.morning.bwqcx.cn.gov.cn.bwqcx.cn http://www.morning.rgmd.cn.gov.cn.rgmd.cn http://www.morning.mjats.com.gov.cn.mjats.com http://www.morning.junyaod.com.gov.cn.junyaod.com http://www.morning.hmxrs.cn.gov.cn.hmxrs.cn http://www.morning.sgfpn.cn.gov.cn.sgfpn.cn http://www.morning.plqsz.cn.gov.cn.plqsz.cn http://www.morning.rnpt.cn.gov.cn.rnpt.cn http://www.morning.dwdjj.cn.gov.cn.dwdjj.cn