{"id":149085,"date":"2020-08-16T04:35:00","date_gmt":"2020-08-15T20:35:00","guid":{"rendered":"http:\/\/4563.org\/?p=149085"},"modified":"2020-08-16T04:35:00","modified_gmt":"2020-08-15T20:35:00","slug":"4-%e5%8d%83%e4%b8%87%e7%9a%84%e6%95%b0%e6%8d%ae%e9%87%8f%ef%bc%8c-postgre-order-by-%e4%bc%98%e5%8c%96%e3%80%82","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=149085","title":{"rendered":"4 \u5343\u4e07\u7684\u6570\u636e\u91cf\uff0c postgre order by \u4f18\u5316\u3002"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  4 \u5343\u4e07\u7684\u6570\u636e\u91cf\uff0c postgre order by \u4f18\u5316\u3002               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xmge <\/span>  <span><i><\/i> 9<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5404\u4f4d\u5927\u4f6c\uff0c\u6709\u4e2a\u8fd9\u6837\u7684\u6570\u636e\u5e93\u4f18\u5316\u95ee\u9898\uff1a<\/p>\n<pre><code>select xxxx,xxx from tables where a &gt; xx order by update limit 100;  a \u548c update \u90fd\u6709\u7d22\u5f15 <\/code><\/pre>\n<p>\u6570\u636e\u91cf 4 \u5343\u4e07\uff0c\u6267\u884c explain analyze \u5206\u6790 sql \u7ed3\u679c\u5982\u4e0b\uff0c\u4e3b\u8981\u7684\u82b1\u8d39\u5728\u4e8e Recheck Cond,<\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u5982\u4f55\u89e3\u51b3\u5462\uff1f\uff1f\uff1f<\/p>\n<pre><code>Sort  (cost=2058.65..2059.93 rows=512 width=89) (actual time=513.218..513.274 rows=333 loops=1)   Sort Key: updated   Sort Method: quicksort  Memory: 74kB   -&gt;  Bitmap Heap Scan on Tables_XXX  (cost=20.53..2035.61 rows=512 width=89) (actual time=15.101..512.814 rows=333 loops=1)         Recheck Cond: ((user_id)::text = 'XXXXXXX'::text)         Heap Blocks: exact=318         -&gt;  Bitmap Index Scan on XXXX_INDEX  (cost=0.00..20.41 rows=512 width=0) (actual time=11.006..11.006 rows=333 loops=1)               Index Cond: ((user_id)::text = 'XXXXXXX'::text) Planning time: 0.089 ms Execution time: 513.320 ms  <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3096956\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : MoYi123 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             min_pk,max_pk = select min(primary_key), max(primary_key) from table where a &gt; xx;<br \/>select xxxx from tables where min_pk &lt; pk and pk &lt; max_pk and a &gt; xx order by update limit 100;<br \/>\u53ef\u4ee5\u8bd5\u4e00\u8bd5\u8fd9\u6837\u6709\u6ca1\u6709\u7528\u3002<br \/>\u53c2\u8003\u4e86\u8fd9\u7bc7\u535a\u5ba2<br \/>https:\/\/github.com\/digoal\/blog\/blob\/master\/202007\/20200710_01.md                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3096957\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : xmge <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @MoYi123 \u597d\u7684\uff0c\u6211\u770b\u4e00\u4e0b\uff0c\u611f\u8c22\u5566                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3096958\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yuan434356430 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u628a postgre \u7684\u5e76\u884c\u6253\u5f00\u8bd5\u8bd5\u4f1a\u4e0d\u4f1a\u53d8\u5feb                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>4 \u5343\u4e07\u7684\u6570\u636e\u91cf\uff0c postgre&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\/149085"}],"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=149085"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/149085\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=149085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=149085"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=149085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}