{"id":201114,"date":"2020-11-24T20:57:13","date_gmt":"2020-11-24T12:57:13","guid":{"rendered":"http:\/\/4563.org\/?p=201114"},"modified":"2020-11-24T20:57:13","modified_gmt":"2020-11-24T12:57:13","slug":"django-postgresql-%e6%95%b0%e6%8d%ae%e5%ba%93%e8%bf%9e%e6%8e%a5%e8%bf%87%e5%a4%9a%e5%af%bc%e8%87%b4-timeout-%e6%83%b3%e9%97%ae%e5%a4%a7%e4%bd%ac%e5%ba%94%e8%af%a5%e5%a6%82%e4%bd%95%e6%8e%92","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=201114","title":{"rendered":"django + postgresql \u6570\u636e\u5e93\u8fde\u63a5\u8fc7\u591a\u5bfc\u81f4 timeout, \u60f3\u95ee\u5927\u4f6c\u5e94\u8be5\u5982\u4f55\u6392\u67e5?"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  django + postgresql \u6570\u636e\u5e93\u8fde\u63a5\u8fc7\u591a\u5bfc\u81f4 timeout, \u60f3\u95ee\u5927\u4f6c\u5e94\u8be5\u5982\u4f55\u6392\u67e5?               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chaleaoch <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4e3b\u8981\u662f\u60f3\u6392\u67e5\u662f\u54ea\u4e2a api \u6216\u8005\u54ea\u51e0\u4e2a api, \u5728\u54ea\u79cd\u60c5\u51b5\u4e0b\u5bfc\u81f4 \u8fde\u63a5\u8fc7\u591a. \u6ca1\u6709\u601d\u8def, \u8bf7\u5927\u4f6c\u6307\u70b9\u4e00\u4e0b.<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4118576\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : liuzhaowei55 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u770b pgsql \u8fde\u63a5\u6570\u8bbe\u7f6e\uff0c\u7136\u540e\u662f\u7a0b\u5e8f\u8fde\u63a5\u6c60\u5927\u5c0f\u662f\u5426\u5408\u7406\uff0c\u7136\u540e\u662f\u67e5\u770b\u6162\u67e5\u8be2\u8fd8\u6709\u9501\u8868\u64cd\u4f5c\uff0c\u6700\u540e\u770b\u770b\u7a0b\u5e8f\u662f\u5426\u5df2\u7ecf\u5230\u4e86\u7406\u8bba\u74f6\u9888                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4118577\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kyrre <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5148\u770b\u770b Pg \u91cc\u7684 slow query log\uff0c\u7136\u540e\u628a\u6700\u6162\u7684\u90a3\u4e9b sql \u8df3\u51fa\u6765 \u5206\u6790\u6267\u884c\u8ba1\u5212\uff0c\u770b\u770b\u662f\u4e0d\u662f\u7528\u4e0a\u4e86\u7d22\u5f15                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4118578\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : encro <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/c4ys.com\/archives\/2349<br \/>Mysql \u5fc5\u77e5\u5fc5\u4f1a &#8212; \u601d\u60f3\u4e0a\u57fa\u672c\u4e5f\u9002\u7528\u4e8e postgres<\/p>\n<p>\u4e8c\u5df2\u7ecf\u8bb2\u4e86\u6700\u91cd\u8981\u7684\uff0c\u6211\u5b8c\u5584\u8865\u5145\u4e0b\uff1a<\/p>\n<p>1\uff0c\u5f00\u542f\u6162\u65e5\u5fd7\uff0c\u8bb0\u5f55\u8fd0\u884c\u6162\u7684\u8bed\u53e5\uff0c\u5e76\u7528\u5de5\u5177\u5206\u6790;<br \/>2, EXPLAIN \u5206\u6790\u6162\u67e5\u8be2<br \/>3\uff0c`select * from pg_stat_activity`\u67e5\u770b\u5f53\u524d\u8fd0\u884c\u7684\u8fdb\u7a0b ;<br \/>4, nginx \u5f00\u542f access \u8bb0\u5f55 cgi \u6267\u884c\u65f6\u95f4\uff1b<br \/>5\uff0c \u9488\u5bf9\u6162\u9875\u9762\u5f00\u542f<\/p>\n<p>\u53c2\u8003\uff1a<\/p>\n<p>* Django \u6570\u636e\u5e93\u8fde\u63a5\u4f18\u5316 https:\/\/docs.djangoproject.com\/zh-hans\/3.1\/topics\/db\/optimization\/<br \/>* Basic Performance Optimization in Django https:\/\/medium.com\/@ryleysill93\/basic-performance-optimization-in-django-ebd19089a33f<br \/>* PostgreSQL Performance Tips https:\/\/www.postgresql.org\/docs\/current\/performance-tips.html                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4118579\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : flyingfz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u9700\u8981 pg-bouncer                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>django + postgres&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/201114"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201114"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/201114\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201114"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}