推荐学习书目
› 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
longmeier90
V2EX  ›  Python

有没有什么方法能够查看 djangoORM 的 SQL 语句消耗时间

  •  
  •   longmeier90 · Jul 6, 2021 · 2818 views
    This topic created in 1950 days ago, the information mentioned may be changed or developed.

    俺们公司的主项目用 django 开发的。其中 SQL 有用自带的 ORM,还有原生的 SQL 语句混合使用,最近 mysql 服务器老是提示 cpu%占用过高。数据库服务器只部署了一个 mysql 。

    11 replies  •  2021-07-06 23:37:40 +08:00
    David1119
    David1119
    Jul 6, 2021
    1
    debug_toolbar
    4771314
    4771314
    Jul 6, 2021
    2
    mysql 有监控的,配置一下就好了(没有的话,建议开启,裸奔还是太危险了)
    如果使用的云服务就更简单了,云服务有配套的服务,直接在控制台就能看到
    est
    est
    Jul 6, 2021❤️1
    3
    'loggers': {
    'django.db': {
    'level': 'DEBUG',
    'handlers': ['console'],
    }
    }
    someios
    someios
    Jul 6, 2021
    4
    profiling ?
    Vegetable
    Vegetable
    Jul 6, 2021
    5
    orm 排查属于侵入式操作了,还是从数据库侧操作吧,如果是云服务的话排查这个应该挺方便的啊
    simple2025
    simple2025
    Jul 6, 2021
    6
    cpu100%应该有会有 slow query 的吧
    GG668v26Fd55CP5W
    GG668v26Fd55CP5W
    Jul 6, 2021 via iPhone
    7
    可以看看 mysql 的 slow log
    ericls
    ericls
    Jul 6, 2021
    9
    @est 3 楼才是最好用的方法
    akira
    akira
    Jul 6, 2021
    10
    正常应该是开 mysql 的慢日志入手吧
    ysw
    ysw
    Jul 6, 2021
    11
    可以考虑 apm 插件,elastic apm 或者其他的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1846 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 09:23 · PVG 17:23 · LAX 01:23 · JFK 04:23
    ♥ Do have faith in what you're doing.