第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Spring 中“排序超出內(nèi)存限制”MongoDb 的問題

Spring 中“排序超出內(nèi)存限制”MongoDb 的問題

ITMISS 2023-01-05 15:34:31
我正在編寫一種使用 MongoRepository 實(shí)現(xiàn)查詢的方法,我在 Java/Spring 項(xiàng)目中使用聚合,但在我測(cè)試時(shí)它超出了內(nèi)存限制。我試過使用newAggregationOptions().cursorBatchSize(pageable.getPageSize()).allowDiskUse(true).build()但沒用我的方法:...        var matchCriteria = match(criteria);        var unwindVariations = unwind("variations", false);        var sort = sort(Sort.Direction.ASC, "variations.plataformStatus.status");        var countResult = count().as("totalElements");        var aggregationOptions = Aggregation.newAggregationOptions().cursorBatchSize(pageable.getPageSize()).allowDiskUse(true).build();        var countAggregation = newAggregation(                matchCriteria,                unwindVariations,                sort,                countResult)                .withOptions(aggregationOptions);        var totalElements = mongoTemplate.aggregate(countAggregation, "PRODUCT", Map.class).getMappedResults();錯(cuò)誤信息:com.mongodb.MongoCommandException: Command failed with error 16819 (Location16819): 'Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.' on server cluster0-shard-00-01-du380.mongodb.net:27017.
查看完整描述

1 回答

?
Smart貓小萌

TA貢獻(xiàn)1911條經(jīng)驗(yàn) 獲得超7個(gè)贊

您應(yīng)該啟用allowDiskUse選項(xiàng)。

默認(rèn)情況下,排序操作有 100MB 的限制(在內(nèi)存中),在您的操作中啟用該選項(xiàng)將允許使用更大的大小。

來自MongoDB 的排序文檔

$sort 階段的 RAM 限制為 100 兆字節(jié)。默認(rèn)情況下,如果階段超過此限制,$sort 將產(chǎn)生錯(cuò)誤。要允許處理大型數(shù)據(jù)集,請(qǐng)將 allowDiskUse 選項(xiàng)設(shè)置為 true 以啟用 $sort 操作以寫入臨時(shí)文件。


查看完整回答
反對(duì) 回復(fù) 2023-01-05
  • 1 回答
  • 0 關(guān)注
  • 243 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)