{"id":1774,"date":"2018-06-20T11:54:30","date_gmt":"2018-06-20T03:54:30","guid":{"rendered":"http:\/\/ufqi.com\/blog\/?p=1774"},"modified":"2018-06-21T11:45:36","modified_gmt":"2018-06-21T03:45:36","slug":"sql-optimize-unique-and-index","status":"publish","type":"post","link":"https:\/\/ufqi.com\/blog\/sql-optimize-unique-and-index\/","title":{"rendered":"SQL\u67e5\u8be2\u4f18\u5316: \u65e2\u6709Unique Index\u4e3a\u4f55\u8fd8\u8981\u53e6\u52a0Index?"},"content":{"rendered":"<p>\u5728\u4f7f\u7528 <a href=\"http:\/\/ufqi.com\/naturedns\/search?q=-gwa2\">-GWA2<\/a> \u8fdb\u884cWebApp\u5f00\u53d1\u65f6\uff0c\u6211\u4eec\u521b\u5efa\u57fa\u4e8eMySQL\u7684\u76f8\u5173\u6570\u636e\u8868\u65f6\uff0c\u90fd\u4f1a\u6709\u610f\u8bc6\u5730\u5728\u6570\u636e\u8868\u7684\u5173\u952e\u5b57\u6bb5\u4e0a\u589e\u52a0\u7d22\u5f15\uff0c\u4ee5\u671f\u5f85\u67e5\u8be2\u65f6\u80fd\u591f\u8f83\u5feb\u5730\u8fd4\u56de\u7ed3\u679c\u96c6\u3002<\/p>\n<p>\u5728\u6211\u4eec\u73b0\u6709\u7684\u751f\u4ea7\u7ebf\u4e0a\u7684\u6570\u636e\u89c2\u6d4b\u4e2d\uff0c\u540c\u6837\u4e00\u5f20\u6570\u636e\u8868\uff0c\u901a\u5e38\u5f53\u6570\u636e\u8fbe\u523010M+\u65f6\uff0c\u5982\u679c\u67d0\u4e2a\u5f85\u68c0\u7d22\u5b57\u6bb5\uff08\u7528\u5728Where\u91cc\u4f5c\u4e3a\u67e5\u8be2\u5b57\u6bb5\uff09\u6ca1\u6709\u4f7f\u7528\u7d22\u5f15\uff0c\u4e00\u6b21\u67e5\u8be2\u5927\u7ea6\u9700\u8981\u8017\u65f650s+\uff0c\u5982\u679c\u589e\u52a0\u4e86\u76f8\u5e94\u7684\u7d22\u5f15\uff0c\u5219\u5355\u6b21\u67e5\u8be2\u5927\u7ea6\u8017\u65f65s\u5de6\u53f3\uff0c\u6027\u80fd\u63d0\u534710\u500d\u4ee5\u4e0a\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u7406\u8bba\u8054\u7cfb\u5b9e\u9645\uff0c\u6211\u4eec\u90fd\u5e94\u8be5\u5728\u76f8\u5173\u5f85\u68c0\u7d22\u7684\u5b57\u6bb5\u4e0a\u589e\u52a0\u7d22\u5f15\uff0c\u8fd9\u6b21\u8981\u63d0\u53ca\u548c\u6f84\u6e05\u7684\u662f\u589e\u52a0Unique Index\u8fd8\u662fIndex? \u53ea\u589e\u52a0Unique Index\uff0c\u8fd8\u662fIndex\u5373\u53ef\uff1f\u6216\u8005\u4e24\u79cdIndex\u90fd\u9700\u8981\uff1f \u5728\u68c0\u7d22\u65b9\u9762\uff0cUnique Index\u4fdd\u6301\u4e86\u6570\u636e\u7684\u552f\u4e00\u6027\uff0c\u5b9e\u9645\u517c\u6709Index\u7684\u529f\u80fd\uff0c\u5728\u88ab\u68c0\u7d22\u65f6\u63d0\u4f9b\u540c\u6837\u7684\u4f18\u5316\u6027\u80fd\u3002<\/p>\n<p>\u60c5\u51b5\u7a0d\u5fae\u590d\u6742\u4e00\u4e9b\u7684\u4f8b\u5b50\u662f\u8fd9\u6837\uff0c\u5f53\u4e00\u4e2aUnique Index\u589e\u52a0\u5230\u591a\u4e2a\u5b57\u6bb5\u7684\u7ec4\u5408\u4e0a\u65f6\uff0c\u5176Index\u7684\u4f5c\u7528\u5e76\u4e0d\u80fd\u60f3\u5f53\u7136\u5730\u5c06Index\u6548\u679c\u8ffd\u52a0\u5230\u6bcf\u4e00\u4e2a\u7ec4\u5408\u4e2d\u7684\u5b57\u6bb5\u4e0a\u3002\u5982\u4e0b\u662f -MySQL \u5b98\u65b9\u6587\u6863\u5bf9\u4e8e\u7ec4\u5408\u5b57\u6bb5\u7684Unique Index\u7684\u63cf\u8ff0\u3002<\/p>\n<p>(\u00a0<b><a class=\"bigfont\" href=\"https:\/\/ufqi.com\/naturedns\/search?q=-R\/u2SN\" target=\"_blank\">-R\/u2SN<\/a>\u00a0<\/b> ) \u201cIf the table has a multiple-column index, any leftmost prefix of the index can be used by the optimizer to look up rows. For example, if you have a three-column index on\u00a0<code class=\"literal\">(col1, col2, col3)<\/code>, you have indexed search capabilities on\u00a0<code class=\"literal\">(col1)<\/code>,\u00a0<code class=\"literal\">(col1, col2)<\/code>, and\u00a0<code class=\"literal\">(col1, col2, col3)<\/code>.<br \/>MySQL cannot use the index to perform lookups if the columns do not form a leftmost prefix of the index. \u201d<\/p>\n<p>\u7528\u7b80\u7565\u5730\u8bdd\u6765\u8bf4\uff0cUnique Index\u7684Index\u4f5c\u7528\uff1a1\uff09\u5f53\u53ea\u6709\u4e00\u4e2a\u5b57\u6bb5\u65f6\uff0c\u5176Index\u4f5c\u7528\u4e5f\u540c\u6837\u5730\u65bd\u52a0\u5230\u8be5\u5b57\u6bb5\u4e0a\uff1b2\uff09\u5f53\u4e3a\u591a\u4e2a\u5b57\u6bb5\u7684\u7ec4\u5408\u65f6\uff0c\u5176Index\u7684\u4f5c\u7528\uff0c\u53ea\u65bd\u52a0\u5230\u7ec4\u5408\u7684\u7b2c\u4e00\u4e2a\u5b57\u6bb5\u4e0a\u3002<\/p>\n<p>\u6240\u8c13\u5dee\u4e4b\u6beb\u5398\uff0c\u8c2c\u4e4b\u5343\u91cc\u3002\u5f53\u5f85\u68c0\u7d22\u7684\u5b57\u6bb5\u662f\u67d0\u4e2aUnique Index\u7684\u7ec4\u5408\u5b57\u6bb5\u4e4b\u4e00\uff0c\u4e14\u4e0d\u662f\u7b2c\u4e00\u4e2a\u65f6\uff0c\u88ab\u7528\u505aWhere\u7684\u67e5\u8be2\u6761\u4ef6\uff0c\u67e5\u8be2\u6027\u80fd\u5c06\u6025\u5267\u4e0b\u964d\uff0c\u6bcf\u6b21\u7686\u662f\u5168\u8868\u626b\u63cf\uff0c\u9010\u884c\u5bf9\u6bd4\u3002<\/p>\n<p>\u8fd9\u79cd\u6027\u80fd\u9690\u60a3\uff0c\u5728\u5f00\u53d1\u521d\u671f\u5e76\u4e0d\u5bb9\u6613\u53d1\u73b0\uff0c\u53ea\u6709\u5f53\u6570\u636e\u91cf\u7ea7\u589e\u957f\u523010M+\u65f6\uff0c\u67e5\u8be2\u8017\u65f6\u624d\u4f1a\u9010\u6b65\u663e\u73b0\u51fa\u6765\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><img src=\"https:\/\/ufqi.com\/blog\/wp-content\/uploads\/2016\/09\/gwa2-logo-201606.v2-300x198.png\" alt=\"gwa2-logo-201606.v2\" \/><\/p>\n<p>-GWA2 \u662f&#8221;\u901a\u7528\u7f51\u7edc\u5e94\u7528\u67b6\u6784( General Web Application Architeture )&#8221;\uff0c\u57fa\u4e8e -GWA2 \u53ef\u4ee5\u8f7b\u4fbf\u6784\u5efa\u5404\u79cd\u7f51\u7edc\u5e94\u7528\u7a0b\u5e8f,\u00a0<br \/>\u5305\u62ec\u590d\u6742\u7684\u5728\u7ebf\u8d2d\u7269\u5546\u57ce\u3001\u00a0\u65c5\u6e38\u4ea4\u6613\u5e73\u53f0\u3001\u793e\u7fa4\u6216\u8005\u793e\u4ea4\u7f51\u7ad9\u548c\u65b0\u95fb\u8d44\u8baf\u7f51\u7ad9\u7b49\uff0c\u00a0<br \/>\u4e5f\u5305\u62ec\u5404\u79cd\u4f01\u4e8b\u4e1a\u5355\u4f4d\u7f51\u4e0a\u95e8\u6237\uff0c\u5728\u7ebf\u4ea4\u4e92\u53ca\u670d\u52a1\u4f5c\u4e1a\u7cfb\u7edf\u7b49.\u00a0<br \/>\u8fd8\u53ef\u4ee5\u5305\u62ec\u4e3aNativeApp\u505a\u670d\u52a1\u5668\u7aef\u652f\u6301, \u751a\u81f3\u662fWebApp\u7684\u5168\u90e8.<br \/>-GWA2 \u662f\u4e3a\u6570\u4e0d\u591a\u7684\u652f\u6301\u8de8\u5f00\u53d1\u8bed\u8a00\u7684\u5e94\u7528\u6846\u67b6\uff0c\u76ee\u524d\u652f\u6301 -Java, -PHP, -Perl, -Aspx and -Python .<br \/>-GWA2 is a &#8220;General Web Application Architecture&#8221;, and based on -GWA2 developers can easily build a variety of network applications,<br \/>Including complex online shopping malls, travel trading platforms, community or social networking sites and news information sites, etc.<br \/>Also the applications include various enterprises and institutions online portals, online interaction and service operations systems.<br \/>And it also includes server-side support for NativeApp, or even all of the WebApp.<br \/>-GWA2 is one of the web frameworks which provide cross-language support for -Java, -PHP, -Perl, -Aspx and -Python at present.<\/p>\n<p><strong>-GWA2 is E.A.S.Y\u00a0<\/strong><br \/><b>Easy Along, Swift Yield<br \/><\/b>\u8f7b\u677e\u542f\u52a8, \u5feb\u901f\u4ea7\u51fa.\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4f7f\u7528 -GWA2 \u8fdb\u884cWebApp\u5f00\u53d1\u65f6\uff0c\u6211\u4eec\u521b\u5efa\u57fa\u4e8eMySQL\u7684\u76f8\u5173\u6570\u636e\u8868\u65f6 &hellip; <a href=\"https:\/\/ufqi.com\/blog\/sql-optimize-unique-and-index\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":1362,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[42,7,2],"tags":[258,255,257,110,256,259],"_links":{"self":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/1774"}],"collection":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/comments?post=1774"}],"version-history":[{"count":7,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/1774\/revisions"}],"predecessor-version":[{"id":1781,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/posts\/1774\/revisions\/1781"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/media\/1362"}],"wp:attachment":[{"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/media?parent=1774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/categories?post=1774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ufqi.com\/blog\/wp-json\/wp\/v2\/tags?post=1774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}