V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
relic
V2EX  ›  Python

Sqlalchemy 优化

  •  
  •   relic · 2016-03-31 16:50:59 +08:00 · 3063 次点击
    这是一个创建于 2950 天前的主题,其中的信息可能已经有所发展或是发生改变。

    今天测了一下, Sqlalchemy 的 ORM 比 CORE 慢一倍,比原生 SQL 请求慢 5 倍+(没有缓存),有什么好的解决办法吗?

    2 条回复    2016-04-01 08:44:39 +08:00
    Lycnir
        1
    Lycnir  
       2016-03-31 17:02:45 +08:00   ❤️ 1
    stranbird
        2
    stranbird  
       2016-04-01 08:44:39 +08:00   ❤️ 1
    具体问题具体分析, SQLAlchemy 对于 count 的实现有一些问题,会用子查询来求 count 。对于这种比较坑的例子,就得用类似于 with_entities('count(1)').as_scalar()来解决了..
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2530 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:47 · PVG 23:47 · LAX 08:47 · JFK 11:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.