小程序
小游戏
企业微信
微信支付
扫描小程序码分享
云函数的执行时间很短,为什么Waiting TTFB时间过长?
是因为我使用了switch case的原因吗?
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
exports.main = async (event, context) => { const { id } = event //const wxContext = cloud.getWXContext() const swiperCollection = db.collection('home_swiper') const footerCollection = db.collection('home_footer') const aboutCollection = db.collection('home_about') const articleCollection = db.collection('article') const eventCollection = db.collection('event') const _ = db.command const recommendRes = await articleCollection .field({ content: false, summary: false }) .where({ recommendPos: _.gt(0), publish: '1' }) .limit(2) .orderBy('recommendPos', 'desc') .get() const edgeRes = await articleCollection .field({ content: false, summary: false }) .where({ edgePos: _.gt(0), publish: '1' }) .orderBy('edgePos', 'desc') .get() const eventRes = await eventCollection .field({ content: false, summary: false }) .where({ recommendPos: _.gt(0), publish: '1' }) .orderBy('recommendPos', 'desc') .get() const aboutRes = await aboutCollection.get() const footerRes = await footerCollection.get() const swiperRes = await swiperCollection .orderBy('pos', 'desc') .get() return { code: 200, msg: 'success', data: { recommendList: recommendRes.data, swiperList: swiperRes.data, eventList: eventRes.data, edgeList: edgeRes.data, about: aboutRes.data[0], footer: footerRes.data[0] } } }
返回数据量很小,其他几个只有一个查询的云函数,差不多也是这么慢
requestID: 70795a8d-f36f-11eb-9899-72475687352d
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
你好,可以提供下相关的requestID
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
exports.main = async (event, context) => { const { id } = event //const wxContext = cloud.getWXContext() const swiperCollection = db.collection('home_swiper') const footerCollection = db.collection('home_footer') const aboutCollection = db.collection('home_about') const articleCollection = db.collection('article') const eventCollection = db.collection('event') const _ = db.command const recommendRes = await articleCollection .field({ content: false, summary: false }) .where({ recommendPos: _.gt(0), publish: '1' }) .limit(2) .orderBy('recommendPos', 'desc') .get() const edgeRes = await articleCollection .field({ content: false, summary: false }) .where({ edgePos: _.gt(0), publish: '1' }) .orderBy('edgePos', 'desc') .get() const eventRes = await eventCollection .field({ content: false, summary: false }) .where({ recommendPos: _.gt(0), publish: '1' }) .orderBy('recommendPos', 'desc') .get() const aboutRes = await aboutCollection.get() const footerRes = await footerCollection.get() const swiperRes = await swiperCollection .orderBy('pos', 'desc') .get() return { code: 200, msg: 'success', data: { recommendList: recommendRes.data, swiperList: swiperRes.data, eventList: eventRes.data, edgeList: edgeRes.data, about: aboutRes.data[0], footer: footerRes.data[0] } } }
返回数据量很小,其他几个只有一个查询的云函数,差不多也是这么慢
requestID: 70795a8d-f36f-11eb-9899-72475687352d
你好,可以提供下相关的requestID