且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

运行sqlite查询后如何加快获取结果的速度?

更新时间:2023-01-31 08:34:42

来自阅读 这个问题,听起来您可以从使用 APSW sqlite 模块.不知何故,您可能是您的 sqlite 模块的受害者,导致您的查询以某种性能较低的方式执行.

From reading this question, it sounds like you could benefit from using the APSW sqlite module. Somehow you may be victim of your sqlite module causing your query to be executed in some less performant manner.

我很好奇所以我自己尝试使用 apsw.这并不太复杂.为什么不试试看呢?

I was curious so I tried using apsw myself. It wasn't too complicated. Why don't you give it a try?

要安装它,我必须:

  1. 提取最新版本.
  2. 让安装包获取最新的 sqlite 合并.

  1. Extract the latest version.
  2. Have the installation package fetch the latest sqlite amalgamation.

python setup.py fetch --sqlite

  • 构建和安装.

  • Build and install.

    sudo python setup.py install
    

  • 使用它代替其他 sqlite 模块.

  • Use it in place of the other sqlite module.

    import apsw
    <...>
    conn = apsw.Connection('foo.db')