{"id":93139,"date":"2020-03-29T05:55:29","date_gmt":"2020-03-28T21:55:29","guid":{"rendered":"http:\/\/4563.org\/?p=93139"},"modified":"2020-03-29T05:55:29","modified_gmt":"2020-03-28T21:55:29","slug":"%e6%96%b0%e8%8f%9c%e9%b8%9f%e8%af%b7%e9%97%ae%e5%90%84%e4%bd%8d%e5%a4%a7%e4%bd%ac-mysql-%e8%83%bd%e4%b8%8d%e8%83%bd%e5%ad%97%e6%ae%b5%e7%ad%89%e4%ba%8e%e6%9f%90%e4%b8%aa%e5%80%bc%e6%89%8d%e5%bb%ba","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=93139","title":{"rendered":"\u65b0\u83dc\u9e1f\u8bf7\u95ee\u5404\u4f4d\u5927\u4f6c MySQL \u80fd\u4e0d\u80fd\u5b57\u6bb5\u7b49\u4e8e\u67d0\u4e2a\u503c\u624d\u5efa\u7acb\u552f\u4e00\u7d22\u5f15"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u65b0\u83dc\u9e1f\u8bf7\u95ee\u5404\u4f4d\u5927\u4f6c MySQL \u80fd\u4e0d\u80fd\u5b57\u6bb5\u7b49\u4e8e\u67d0\u4e2a\u503c\u624d\u5efa\u7acb\u552f\u4e00\u7d22\u5f15               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 353943780 <\/span>  <span><i><\/i> 23<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p><code>a<\/code> \/ <code>b<\/code> \/ <code>c<\/code> \u90fd\u662f\u5b57\u6bb5\u540d<\/p>\n<p>(a = 1) + b + c \u662f\u552f\u4e00\u7d22\u5f15<\/p>\n<p>(a != 1) + b + c \u53ef\u91cd\u590d<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>6<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1006722\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : b821025551b <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u4e0d\u61c2\uff0ca \u90fd\u662f\u5b57\u6bb5\u540d\u4e86\uff0c\u600e\u4e48\u53bb==1                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1006723\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : 353943780 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @b821025551b \u53ef\u80fd\u662f\u6211\u63cf\u8ff0\u4e0d\u6e05\u695a\uff0c\u5982\u679c\u6570\u636e\u8bb0\u5f55\u4e2d a \u5b57\u6bb5\u503c\u4e3a 1 \u7684\u65f6\u5019\uff0c\u4e0e\u5b57\u6bb5 b \u3001c \u8054\u5408\u4e3a\u552f\u4e00                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1006724\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : scriptB0y <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6709\u4e00\u79cd\u7d22\u5f15\u53eb\u505a partial index\uff0c\u53ef\u4ee5\u6839\u636e\u6761\u4ef6\u5efa\u7acb\u7d22\u5f15\u3002\u4f60\u8fd9\u79cd\u60c5\u51b5\u53ef\u4ee5<\/p>\n<p>create unique index unique_b_c_if_a_is_one on partial_index(b,c) where a=&#8217;1&#8242;;<\/p>\n<p>\u7136\u540e\u518d\u521b\u5efa\u4e00\u4e2a\u7d22\u5f15<\/p>\n<p>create index unique_b_c_if_a_not_one on partial_index(b,c) where a!=&#8217;1&#8242;;<\/p>\n<p>\u5c31\u53ef\u4ee5\u6ee1\u8db3\u4f60\u7684\u9700\u6c42\u3002\u4f46\u662f\u636e\u6211\u6240\u77e5 postgres \uff08 https:\/\/www.postgresql.org\/docs\/9.3\/indexes-unique.html \uff09 \u548c SQL Server \u652f\u6301\u8fd9\u79cd\u7d22\u5f15\uff0cmysql \u76ee\u524d\u5e94\u8be5\u4e0d\u652f\u6301\u3002<\/p>\n<p>\u4e0d\u77e5\u9053\u6709\u6ca1\u6709\u5176\u4ed6\u65b9\u6848\u54c8\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1006725\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lysS <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u628a\u90a3\u4e24\u4e2d\u60c5\u51b5\u5206\u6210\u4e24\u4e2a\u8868\u561b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1006726\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rrfeng <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             mongodb \u4e5f\u652f\u6301 partial index<\/p>\n<p>\u62c6\u4e00\u4e0b\u8868\u5427\u3002\u6216\u8005\u53e6\u5916\u52a0\u903b\u8f91\u53bb\u91cd\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1006727\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : MonoLogueChi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u6e05\u695a mysql \u6709\u6ca1\u6709\u8fd9\u79cd\u64cd\u4f5c\uff0c\u4f46\u662f\u6211\u77e5\u9053 postgresql \u6709\u8fd9\u6837\u7684\u7d22\u5f15\uff0c\u53eb\u505a Partial Indexes\uff0c<\/p>\n<p>CREATE INDEX xxx_index ON table1(col1) WHERE col2 is not true;<\/p>\n<p>mysql \u6211\u7528\u7684\u4e0d\u591a\uff0c\u4e0d\u592a\u6e05\u695a\u6709\u6ca1\u6709\u8fd9\u79cd\u4e1c\u897f\uff0c\u4f60\u53ef\u4ee5\u987a\u7740\u8fd9\u4e2a\u601d\u8def\u67e5\u4e00\u4e0b                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u65b0\u83dc\u9e1f\u8bf7\u95ee\u5404\u4f4d\u5927\u4f6c MySQL \u80fd&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\/93139"}],"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=93139"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/93139\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=93139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=93139"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=93139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}