反馈人:李冠
问题1:
OZON严重慢SQL,通过SQL分析,当前技术方案有严重性能问题,造成SQL执行几百秒还在执行中,当前SQL为:
SELECT id,customer_id,source_id,sku,pf_listing_id,source_sku,category_id,category_name,title,title_id,pf_quantity,price,image,description,calculation_formula_id,status,type,remark,create_time,update_time,is_deleted,strategy_name,country_code FROM t_strategy_pool_publish_ozon
WHERE (source_id = 26686 AND status = 0 AND update_time <= 2025-10-20 15:50:40 AND is_deleted = 0) ORDER BY type ASC limit 200

解决方案:建议查询条件有开始与结束时间,如update_time <= 2025-10-20 15:50:40 and update_time <= 2025-10-17 15:50:40,仅查3内天的(时间区间可以根据业务情况定),超过时间区间的,也没必要刊登了(视为超时失败)
问题2:
onbuy严重mongodb慢查询,查询时间20秒左右,华为云记录的慢查询命令如下:
{
"username": "rwuser",
"ns": "zhcxkj_comprehensive_shopee.t_onbuy_publish_platform_param",
"op": "query",
"millis": 16778,
"docsExamined": 477928,
"keysExamined": 0,
"nreturned": 0,
"ndeleted": 0,
"ninserted": 0,
"nMatched": 0,
"nModified": 0,
"ts": {
"date": 1760940054322
},
"clientIp": "10.17.47.60",
"locks": {
"Global": {
"acquireCount": {
"r": 3869
},
"timeWaitingTicketMicros": {
"r": 51
}
},
"Database": {
"acquireCount": {
"r": 3869
}
},
"Collection": {
"acquireCount": {
"r": 3869
}
}
},
"command": "{ find: "t_onbuy_publish_platform_param", filter: { queue_detail_id: { in: [ 2084982, 2084985, 2084986, 2084991 ] } }, projection: { sortKey: { meta: "sortKey" } }, sort: { queue_detail_id: -1 }, shardVersion: [ Timestamp(34, 0), ObjectId(68b6a5d599f786f046a5e624) ], lsid: { id: UUID("09caf21a-dbf9-442b-8516-53417de51b49"), uid: BinData(0, 109178812F0C2E953B72EBAB4C7B30ADD8C5E612275C84C7DFBF7A9DE713ECF5) }, clusterTime: { clusterTime: Timestamp(1760940037, 13780), signature: { hash: BinData(0, ADF69864A5170C70CB9C77BB8E384CF5DAA599DC), keyId: 7527127265109344260 } }, client: { driver: { name: "mongo-java-driver|sync", version: "4.6.1" }, os: { type: "Linux", name: "Linux", architecture: "amd64", version: "4.18.0-147.5.1.6.h1152.eulerosv2r9.x86_64" }, platform: "Java/Oracle Corporation/17.0.2+8-86", mongos: { host: "host-192-168-63-158:8635", client: "10.17.47.60:42846", version: "4.0.3" }, username: "rwuser" }, configServerState: { opTime: { ts: Timestamp(1760940037, 11912), t: 6 } }, db: "zhcxkj_comprehensive_shopee" }",
"original_log": "2025-10-20T06:00:54.322+0000 I COMMAND [conn2416585] command zhcxkj_comprehensive_shopee.t_onbuy_publish_platform_param clientIp: 10.17.47.60 username: rwuser command: find { find: "t_onbuy_publish_platform_param", filter: { queue_detail_id: { in: [ 2084982, 2084985, 2084986, 2084991 ] } }, projection: { sortKey: { meta: "sortKey" } }, sort: { queue_detail_id: -1 }, shardVersion: [ Timestamp(34, 0), ObjectId(68b6a5d599f786f046a5e624) ], lsid: { id: UUID("09caf21a-dbf9-442b-8516-53417de51b49"), uid: BinData(0, 109178812F0C2E953B72EBAB4C7B30ADD8C5E612275C84C7DFBF7A9DE713ECF5) }, clusterTime: { clusterTime: Timestamp(1760940037, 13780), signature: { hash: BinData(0, ADF69864A5170C70CB9C77BB8E384CF5DAA599DC), keyId: 7527127265109344260 } }, client: { driver: { name: "mongo-java-driver|sync", version: "4.6.1" }, os: { type: "Linux", name: "Linux", architecture: "amd64", version: "4.18.0-147.5.1.6.h1152.eulerosv2r9.x86_64" }, platform: "Java/Oracle Corporation/17.0.2+8-86", mongos: { host: "host-192-168-63-158:8635", client: "10.17.47.60:42846", version: "4.0.3" }, username: "rwuser" }, configServerState: { opTime: { ts: Timestamp(1760940037, 11912), t: 6 } }, db: "zhcxkj_comprehensive_shopee" } planSummary: COLLSCAN keysExamined:0 docsExamined:477928 hasSortStage:1 cursorExhausted:1 numYields:3868 nreturned:0 reslen:442 locks:{ Global: { acquireCount: { r: 3869 }, timeWaitingTicketMicros: { r: 51 } }, Database: { acquireCount: { r: 3869 } }, Collection: { acquireCount: { r: 3869 } } } protocol:op_msg 16778ms"
}

解决方案:1、定期删除数据(时间更短一些);2、增加分片键查询
(其实不建议把请求参数落库,有异常的打印日志,在华为云LTS查则可,如果太多异常,得问自己的技术方案了)
已完成