云数据库接口调用警告调用时间超过3秒怎么解决?

发布于 9 年前作者 wanyong8523 次浏览最后编辑 9 年前来自 ask

代码很简单,没有复杂的查询,但是仍旧报调用时间超过3秒的告警。运行环境是云函数。

Database operation database.queryDocument is longer than 3s. Please check query performance and your network environment.

async function getHelpMark(result) {
  console.log("qzid:" + result.qzid)
  return new Promise(function(resolve, reject) {
    let db = cloud.database()
    let t_quizzes = db.collection('quizzes')
    t_quizzes.doc(result.qzid)
      .field({ helpMark: true })
      .get().then(res => {
        console.log(res)
        resolve({
          qzid: result.qzid,
          helpMark: res.data.helpMark
      })
    })
  })
}

看不出有什么影响效率的地方,请高手指点迷津,谢谢!

4 回复
luochao
luochao1 楼6 年前

时间不够可以在后台设置超时时间,

leicui
leicui2 楼6 年前

你云函数代码不止这个方法吧

qiang26
qiang263 楼6 年前

这个问题是否解决了呢?我们今天突然也是出现这个问题

yongren
yongren4 楼6 年前
.field({ helpMark:true })

把这个给去掉,不能这么写