{"id":108,"date":"2020-10-01T01:00:23","date_gmt":"2020-09-30T17:00:23","guid":{"rendered":"https:\/\/www.mengqingzhong.com\/?p=108"},"modified":"2024-01-14T11:38:30","modified_gmt":"2024-01-14T03:38:30","slug":"postgresql-index-introduction-1","status":"publish","type":"post","link":"https:\/\/www.mengqingzhong.com\/2020\/10\/01\/postgresql-index-introduction-1\/","title":{"rendered":"PostgreSQL\u7d22\u5f15(1) – \u7b80\u4ecb"},"content":{"rendered":"

\n\u672c\u6587\u7ffb\u8bd1\u81eaEgor Rogov\u7684\u82f1\u6587\u535a\u5ba2<\/a>\uff0c\u4e14\u5df2\u5f81\u5f97Egor Rogov\u7684\u540c\u610f\u3002\u8bd1\u8005\u505a\u4e86\u5c11\u91cf\u4fee\u6539\uff0c\u5e76\u6dfb\u52a0\u4e86\u5c11\u91cf\u5185\u5bb9\u3002\n<\/p>\n

\n\u5ba1\u6821\uff1a\u7eaa\u6600\u7ea2\uff0c\u4e2d\u56fd\u4eba\u6c11\u5927\u5b66\u4fe1\u606f\u5b66\u9662\u5728\u8bfb\u535a\u58eb\u751f\u3002\n<\/p>\n

\u672c\u7cfb\u5217\u6587\u7ae0\u5c06\u4ecb\u7ecdPostgreSQL\uff08\u540e\u6587\u7b80\u79f0PG\uff09\u7684\u7d22\u5f15\u3002<\/p>\n

\u6a2a\u770b\u6210\u5cad\u4fa7\u6210\u5cf0\uff0c\u8fdc\u8fd1\u9ad8\u4f4e\u5404\u4e0d\u540c\u3002\u4efb\u4f55\u4e8b\u7269\u90fd\u6709\u591a\u4e2a\u89d2\u5ea6\uff0c\u6211\u4eec\u5c06\u4ece\u6570\u636e\u5e93\u4f7f\u7528\u8005\u3001\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u8005\u7684\u89d2\u5ea6\u7814\u7a76PG\u7684\u7d22\u5f15\uff0c\u8ba8\u8bba\u4ed6\u4eec\u5e94\u8be5\u5173\u5fc3\u7684\u95ee\u9898\u3002\u7d22\u5f15\u6709\u54ea\u4e9b\u79cd\u7c7b\uff1f\u4e3a\u4ec0\u4e48\u4f1a\u6709\u8fd9\u4e48\u591a\u4e0d\u540c\u7684\u79cd\u7c7b\uff1f\u5982\u4f55\u4f7f\u7528\u7d22\u5f15\u624d\u80fd\u52a0\u901f\u67e5\u8be2\uff1f\u8fd9\u4e2a\u8bdd\u9898\u6216\u8bb8\u53ef\u4ee5\u4f7f\u7528\u7b80\u7ec3\u7684\u6587\u5b57\u52a0\u4ee5\u6982\u62ec\uff0c\u4f46\u6211\u4eec\u5e0c\u671b\u5f00\u53d1\u8005\u80fd\u591f\u6df1\u6316\u4e00\u4e9b\uff0c\u5bf9\u7d22\u5f15\u7684\u5185\u90e8\u5b9e\u73b0\u7ec6\u8282\u6709\u6240\u4e86\u89e3\uff0c\u505a\u5230\u77e5\u5176\u7136\uff0c\u4e14\u77e5\u5176\u6240\u4ee5\u7136\u3002\u9047\u5230\u95ee\u9898\u53ef\u4ee5\u81ea\u5df1\u5206\u6790\u5e76\u5f97\u51fa\u7ed3\u8bba\uff0c\u907f\u514d\u751f\u642c\u786c\u5957\u524d\u4eba\u7684\u7ecf\u9a8c\u3002<\/p>\n

\u672c\u7cfb\u5217\u6587\u7ae0\u4e0d\u8ba8\u8bba\u5982\u4f55\u5b9e\u73b0\u65b0\u7684\u7d22\u5f15\u7c7b\u578b\uff0c\u8fd9\u9700\u8981C\u8bed\u8a00\u7684\u7f16\u7a0b\u77e5\u8bc6\u548c\u7cfb\u7edf\u7a0b\u5e8f\u5458\u7684\u4e13\u4e1a\u77e5\u8bc6\u3002\u4e5f\u4e0d\u8ba8\u8bba\u7d22\u5f15\u7684\u7f16\u7a0b\u63a5\u53e3\uff0c\u800c\u662f\u805a\u7126\u5728\u5df2\u6709\u7d22\u5f15\u7c7b\u578b\u7684\u4e00\u4e9b\u91cd\u8981\u77e5\u8bc6\u70b9\u3002<\/p>\n

\u672c\u6587\u5c06\u8ba8\u8bbaPG\u5185\u6838\u4e2d\u901a\u7528\u7d22\u5f15\u5f15\u64ce<\/strong>\u548c\u5b58\u53d6\u65b9\u6cd5<\/strong>\uff08Access Method, \u4e0b\u9762\u7b80\u79f0AM\uff09\u7684\u8d23\u4efb\u5212\u5206\uff0c\u4ee5\u53ca\u7d22\u5f15\u5f15\u64ce\u7684\u529f\u80fd\u3002\u4e0b\u7bc7\u8ba8\u8bbaAM\u7684\u63a5\u53e3\u548c\u5176\u5b83\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u6bd4\u5982classes\u3001operator families\u3002\u4ece\u7b2c\u4e09\u7bc7\u5f00\u59cb\u5c06\u4f9d\u6b21\u7814\u7a76Hash\u3001B-tree\u3001GiST\u3001 SP-GiST\u3001GIN\u3001RUM\u3001BRIN\u3001Bloom\u7684\u7d22\u5f15\u7684\u7ed3\u6784\u548c\u5e94\u7528\u573a\u666f\u3002<\/p>\n

1. \u7d22\u5f15<\/h1>\n

\u5728PG\u4e2d\uff0c\u7d22\u5f15\u662f\u4e00\u79cd\u4e3b\u8981\u7528\u6765\u52a0\u901f\u8bbf\u95ee\u7684\u6570\u636e\u5e93\u5bf9\u8c61\u3002\u5b83\u4eec\u662f\u4e00\u79cd\u8f85\u52a9\u7684\u7ed3\u6784\uff1a\u6bcf\u4e2a\u7d22\u5f15\u88ab\u5220\u9664\u4e4b\u540e\uff0c\u90fd\u53ef\u4ee5\u6839\u636e\u57fa\u8868\u4e2d\u7684\u4fe1\u606f\u8fdb\u884c\u91cd\u5efa\u3002\u6709\u65f6\u4f60\u53ef\u80fd\u542c\u8bf4\u5373\u4f7f\u6570\u636e\u5e93\u6ca1\u6709\u7d22\u5f15\u4e5f\u53ef\u4ee5\u5de5\u4f5c\uff0c\u53ea\u662f\u6162\u4e00\u4e9b\u800c\u5df2\u3002\u4f46\u4e8b\u5b9e\u5e76\u975e\u5982\u6b64\uff0c\u56e0\u4e3a\u67d0\u4e9b\u4e00\u81f4\u6027\u7ea6\u675f\u9700\u8981\u7528\u7d22\u5f15\u5b9e\u73b0\u3002<\/p>\n

PG 9.6\u5185\u7f6e\u4e866\u79cd\u4e0d\u540c\u7684\u7d22\u5f15\uff0c\u518d\u52a0\u4e00\u79cd\u53ef\u4ee5\u901a\u8fc7extension\uff08\u63d2\u4ef6\uff09\u83b7\u5f97\u7684\u7d22\u5f15 \u2014\u2014 \u611f\u8c22PG 9.6\u7684\u91cd\u5927\u6539\u8fdb\u3002\u671f\u5f85\u5728\u4e0d\u4e45\u7684\u5c06\u6765\u53ef\u4ee5\u6709\u65b0\u7684\u7d22\u5f15\u7c7b\u578b\u51fa\u73b0\u3002<\/p>\n

\u867d\u7136\u4e0d\u540c\u7d22\u5f15\u7c7b\u578b(\u4e5f\u88ab\u79f0\u4e3aAccess Method)\u4e4b\u95f4\u5b58\u5728\u5404\u79cd\u5dee\u5f02\uff0c\u4f46\u662f\u5b83\u4eec\u6700\u7ec8\u90fd\u628a\u4e00\u4e2akey\uff08\u4f8b\u5982\uff0c\u7d22\u5f15\u5217\u7684\u503c\uff09\u548c\u8868\u4e2d\u5305\u542b\u8fd9\u4e2akey\u7684\u90a3\u884c\u6570\u636e\u76f8\u5173\u8054\u3002\u6bcf\u884c\u6570\u636e\u7528TID\uff08tuple id\uff09\u8868\u793a\uff0cTID\u5305\u542b\u57fa\u8868\u6570\u636e\u6587\u4ef6\u4e2d\u7684\u5757\u53f7\u548c\u8fd9\u884c\u6570\u636e\u5728\u5757\u5185\u7684\u4f4d\u7f6e\u3002\u56e0\u6b64\uff0c\u53ea\u8981\u77e5\u9053\u4e00\u4e2akey\u6216\u5b83\u7684\u4e00\u4e9b\u4fe1\u606f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5feb\u901f\u5728\u8868\u4e2d\u627e\u5230\u6211\u4eec\u53ef\u80fd\u9700\u8981\u7684\u90a3\u4e9b\u884c\uff0c\u800c\u65e0\u9700\u626b\u63cf\u6574\u5f20\u8868\u3002<\/p>\n

\u503c\u5f97\u6ce8\u610f\u7684\u65f6\uff0c\u867d\u7136\u7d22\u5f15\u53ef\u4ee5\u52a0\u901f\u67e5\u8be2\uff0c\u4f46\u662f\u7ef4\u62a4\u7d22\u5f15\u4e5f\u9700\u8981\u4e00\u4e9b\u4ee3\u4ef7\u3002\u5bf9\u8868\u8fdb\u884c\u63d2\u5165\u3001\u5220\u9664\uff0c\u4fee\u6539\u65f6\uff0c\u6b64\u8868\u5bf9\u5e94\u7684\u7d22\u5f15\u4e5f\u90fd\u9700\u8981\u88ab\u66f4\u65b0\uff0c\u5e76\u4e14\u9700\u8981\u5728\u540c\u4e00\u4e2a\u4e8b\u52a1\u5185\u3002\u5bf9\u8868\u4e2d\u7684\u975e\u7d22\u5f15\u5217\u8fdb\u884c\u66f4\u65b0\uff0c\u53ef\u80fd\u4e0d\u9700\u8981\u66f4\u65b0\u7d22\u5f15\uff0c\u8fd9\u4e2a\u6280\u672f\u88ab\u79f0\u4e3aHOT\uff08Heap-Only Tuples\uff09\u3002<\/p>\n

PG\u7684\u7d22\u5f15\u5b9e\u73b0\u5206\u4e3a\u901a\u7528\u7684\u7d22\u5f15\u5f15\u64ce\u548c\u5177\u4f53\u7684AM\uff0c\u7d22\u5f15\u5f15\u64ce\u5904\u5728AM\u7684\u4e0a\u5c42\uff0cAM\u4e3a\u7d22\u5f15\u5f15\u64ce\u670d\u52a1\u3002\u89e3\u8026\u7684\u76ee\u7684\u662f\u4e3a\u4e86\u5b9e\u73b0\u9ad8\u6269\u5c55\u6027\uff0c\u4e3a\u4e86\u66f4\u65b9\u4fbf\u5730\u6dfb\u52a0\u65b0\u7684AM\u3002\u6269\u5c55\u9700\u8981\u9075\u5faa\u4e00\u5b9a\u7684\u89c4\u5219\uff0c\u7d22\u5f15\u5f15\u64ce\u5b9e\u73b0\u4e86\u4e00\u4e2a\u63a5\u53e3\uff0c\u5b83\u4e3b\u8981\u7684\u7528\u9014\u662f\u4eceAM\u4e2d\u83b7\u53d6TID\uff0c\u5e76\u4e14\u5bf9\u5b83\u4eec\u8fdb\u884c\u5904\u7406\uff1a<\/p>\n

    \n
  • \u4eceAM\u5c42\u83b7\u53d6\u4e00\u4e2aTID\u3001\u6216\u4e00\u4e2a\u8868\u793a\u5019\u9009TID\u7684\u4f4d\u56fe<\/li>\n
  • \u4f7f\u7528TID\u4ece\u57fa\u8868\u4e2d\u83b7\u53d6\u4e00\u884c\u6570\u636e<\/li>\n
  • \u68c0\u67e5\u8fd9\u884c\u6570\u636e\u5728\u5f53\u524d\u9694\u79bb\u7ea7\u522b\u4e0b\u5bf9\u5f53\u524d\u4e8b\u52a1\u662f\u5426\u53ef\u89c1<\/li>\n<\/ul>\n

    \u5982\u679c\u4f18\u5316\u5668\u751f\u6210\u4e86\u4f7f\u7528\u7d22\u5f15\u7684\u6267\u884c\u8ba1\u5212\uff0c\u5219\u7d22\u5f15\u5f15\u64ce\u53c2\u4e0e\u67e5\u8be2\u7684\u6267\u884c\u3002\u4f18\u5316\u5668\u5728\u751f\u6210\u8ba1\u5212\u65f6\uff0c\u4f1a\u5148\u751f\u6210\u591a\u79cd\u5019\u9009\u8ba1\u5212\uff0c\u5e76\u4e14\u5bf9\u5404\u79cd\u5019\u9009\u8ba1\u5212\u8ba1\u7b97\u6267\u884c\u4ee3\u4ef7\uff0c\u6839\u636e\u5019\u9009\u8ba1\u5212\u7684\u4ee3\u4ef7\u9009\u51fa\u6700\u4f18\u8ba1\u5212\u3002\u4e3a\u4e86\u751f\u6210\u5019\u9009\u8ba1\u5212\uff0c\u4f18\u5316\u5668\u9700\u8981\u4e86\u89e3\u5404\u79cdAM\u7684\u5c5e\u6027\u3002\u8fd9\u4e2aAM\u53ef\u4ee5\u6309\u6240\u9700\u7684\u987a\u5e8f\u8fd4\u56de\u6570\u636e\u5417\uff1f\u6211\u4eec\u9700\u8981\u6570\u636e\u6709\u5e8f\u5417\uff1f\u8fd9\u4e2aAM\u53ef\u4ee5\u67e5\u627eNULL\u503c\u5417\uff1f\u8fd9\u4e9b\u90fd\u662f\u4f18\u5316\u5668\u7ecf\u5e38\u9700\u8981\u8003\u8651\u7684\u95ee\u9898\u3002<\/p>\n

    \u4e0d\u4ec5\u4f18\u5316\u5668\u9700\u8981\u4e86\u89e3AM\u7684\u5c5e\u6027\uff0c\u5f53\u521b\u5efa\u4e00\u4e2a\u7d22\u5f15\u65f6\uff0c\u7cfb\u7edf\u4e5f\u5fc5\u987b\u77e5\u9053\u80fd\u5426\u5728\u8fd9\u4e9b\u5217\u4e0a\u5efa\u7acb\u8fd9\u4e2a\u7d22\u5f15\uff0c\u4ee5\u53ca\u8fd9\u4e2a\u7d22\u5f15\u662f\u5426\u6709\u552f\u4e00\u6027\u8981\u6c42\u7b49\u3002<\/p>\n

    \u6240\u4ee5\uff0c\u6bcf\u4e2aAM\u90fd\u5fc5\u987b\u63d0\u4f9b\u5173\u4e8e\u5b83\u7684\u4e00\u4e9b\u5c5e\u6027\u4fe1\u606f\u3002\u5728PG 9.6\u4e4b\u524d\uff0c\u4f7f\u7528pg_am\u7cfb\u7edf\u8868\u4fdd\u5b58\u8fd9\u4e9b\u4fe1\u606f\uff0cPG 9.6\u4ee5\u540e\uff0c\u8fd9\u4e9b\u4fe1\u606f\u4e0b\u79fb\u5230\u66f4\u6df1\u7684\u5c42\u6b21\uff08\u786c\u7f16\u7801\u5728PG\u5185\u6838\u4ee3\u7801\u4e2d\uff09\uff0c\u9700\u8981\u4f7f\u7528\u4e13\u95e8\u7684\u51fd\u6570\u67e5\u8be2\u8fd9\u4e9b\u4fe1\u606f\u3002\u6211\u4eec\u5c06\u5728\u4e0b\u4e00\u7bc7\u8fdb\u4e00\u6b65\u7814\u7a76\u8fd9\u4e9b\u63a5\u53e3\u3002<\/p>\n

    AM\u7684\u5176\u5b83\u4f5c\u7528\uff1a<\/p>\n

      \n
    • \u5b9e\u73b0\u7d22\u5f15\u7684\u521b\u5efa\u7b97\u6cd5\uff0c\u5e76\u4e14\u5c06\u7d22\u5f15\u6570\u636e\u6309\u9875\u5b58\u653e\uff08\u4e3a\u4e86\u8ba9\u7f13\u5b58\u533a\u7ba1\u7406\u5668\u7edf\u4e00\u5904\u7406\u6bcf\u4e2a\u7d22\u5f15\uff09\u3002<\/li>\n
    • \u4f7f\u7528”indexed-field operator expression”\u5f62\u5f0f\u7684\u8c13\u8bcd\u6761\u4ef6\u5728\u7d22\u5f15\u4e2d\u8fdb\u884c\u67e5\u8be2<\/li>\n
    • \u8ba1\u7b97\u4f7f\u7528\u7d22\u5f15\u7684\u4ee3\u4ef7\u3002<\/li>\n
    • \u5bf9\u9501\u8fdb\u884c\u7ba1\u7406\uff0c\u4ee5\u4fbf\u652f\u6301\u5e76\u53d1\u5904\u7406<\/li>\n
    • \u751f\u6210WAL\u65e5\u5fd7<\/li>\n<\/ul>\n

      \u672c\u6587\u4e0b\u9762\u5c06\u7814\u7a76\u901a\u7528\u7d22\u5f15\u5f15\u64ce\u7684\u529f\u80fd\uff0c\u540e\u7eed\u6587\u7ae0\u7814\u7a76\u4e0d\u540c\u7684AM\u3002<\/p>\n

      2. \u7d22\u5f15\u5f15\u64ce<\/h1>\n

      \u7d22\u5f15\u5f15\u64ce\u53ef\u4ee5\u4f7fPG\u5bf9\u5404\u79cdAM\u8fdb\u884c\u7edf\u4e00\u5904\u7406\uff0c\u540c\u65f6\u517c\u987e\u5b83\u4eec\u5404\u81ea\u7684\u7279\u70b9\u3002<\/p>\n

      2.1 \u5e38\u7528\u626b\u63cf\u65b9\u6cd5<\/h2>\n

      2.1.1 \u7d22\u5f15\u626b\u63cf<\/h3>\n

      \u8003\u8651\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a<\/p>\n

      create table t(a integer, b text, c boolean);\n\ninsert into t(a,b,c)\n  select s.id, chr((32+random()*94)::integer), random() < 0.01\n  from generate_series(1,100000) as s(id)\n  order by random();\n\ncreate index on t(a);\n\nanalyze t;\n<\/code><\/pre>\n

      \u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542ba\u3001b\u3001c\u4e09\u5217\u7684\u8868\u3002\u5176\u4e2d\uff0ca\u5217\u7684\u503c\u4ece1\u5230100000\uff0c\u5e76\u4e14\u5728a\u5217\u4e0a\u521b\u5efa\u4e86\u4e00\u4e2a\u7d22\u5f15\uff08\u6682\u65f6\u4e0d\u5173\u5fc3\u7d22\u5f15\u7684\u7c7b\u578b\uff09\uff1bb\u5217\u7684\u503c\u662f\u4e00\u4e9b\u968f\u673a\u7684\u53ef\u6253\u5370\u5b57\u7b26\uff1bc\u5217\u7684\u503c\u4e2d1%\u4e3atrue\uff0c\u5176\u4f59\u4e3afalse\u3002\u8fd9\u4e9b\u884c\u4ee5\u968f\u673a\u7684\u987a\u5e8f\u63d2\u5165\u5230\u8868\u4e2d\uff08\u6ce8\u610forder by random()\u5b50\u53e5\uff09\u3002<\/p>\n

      \u4f7f\u7528a=1\u4e3a\u6761\u4ef6\u67e5\u8be2\u6b64\u8868\u3002\u53ef\u4ee5\u53d1\u73b0\uff0c\u8fd9\u4e2a\u6761\u4ef6\u7b26\u5408\u8fd9\u4e2a\u5f62\u5f0f\uff1aindexed-field operator expression\u3002\u5176\u4e2doperater\u662f\u201c=\u201d\uff0cexpression\uff08search key\uff09\u662f1\u3002\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u7b26\u5408\u8fd9\u4e2a\u5f62\u5f0f\u7684\u6761\u4ef6\u624d\u80fd\u88ab\u7d22\u5f15\u4f7f\u7528\u3002<\/p>\n

      explain (costs off) select * from t where a = 1;\n<\/code><\/pre>\n
                QUERY PLAN          \n-------------------------------\n Index Scan using t_a_idx on t\n   Index Cond: (a = 1)\n(2 rows)\n<\/code><\/pre>\n

      \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u4f18\u5316\u5668\u51b3\u5b9a\u4f7f\u7528\u7d22\u5f15\u626b\u63cf\u3002\u4f7f\u7528\u7d22\u5f15\u626b\u63cf\u65f6\uff0cAM\u4e00\u6b21\u53ea\u8fd4\u56de\u4e00\u4e2aTID\uff0c\u76f4\u5230\u6700\u540e\u4e00\u884c\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u3002\u7d22\u5f15\u5f15\u64ce\u4f9d\u6b21\u4f7f\u7528\u8fd9\u4e9bTID\u83b7\u53d6\u8868\u4e2d\u7684\u884c\u6570\u636e\uff0c\u68c0\u67e5\u8fd9\u884c\u6570\u636e\u662f\u5426\u5bf9\u672c\u4e8b\u52a1\u53ef\u89c1\u3002\u5982\u679c\u53ef\u89c1\u5219\u5411\u4e0a\u5c42\u8fd4\u56de\u5b83\u6240\u83b7\u53d6\u7684\u6570\u636e\uff0c\u5426\u5219\u7ee7\u7eed\u8c03\u7528AM\u83b7\u53d6\u4e0b\u4e00\u4e2aTID\u3002<\/p>\n

      2.1.2 \u4f4d\u56fe\u626b\u63cf<\/h3>\n

      \u5f53\u6ee1\u8db3\u6761\u4ef6\u7684\u6570\u636e\u884c\u6570\u5f88\u5c11\u65f6\uff0c\u4f7f\u7528\u7d22\u5f15\u626b\u63cf\u5341\u5206\u9ad8\u6548\u3002\u4f46\u5f53\u6ee1\u8db3\u6761\u4ef6\u7684\u884c\u6570\u589e\u52a0\u65f6\uff0c\u53ef\u80fd\u9700\u8981\u5728\u591a\u6b21\u8bbf\u95ee\u540c\u4e00\u4e2a\u9875\u9762\uff0c\u5e76\u4e14\u5728\u591a\u4e2a\u9875\u9762\u4e4b\u95f4\u6765\u56de\u8df3\u8dc3\uff0c\u800c\u4e0d\u662f\u4e00\u6b21\u6027\u5c06\u67d0\u4e2a\u57fa\u8868\u9875\u9762\u4e0a\u6ee1\u8db3\u6761\u4ef6\u7684\u6570\u636e\u884c\u5168\u90e8\u8bfb\u53d6\u51fa\u6765\uff0c\u5bfc\u81f4\u67e5\u8be2\u6027\u80fd\u975e\u6700\u4f18\u3002\u6b64\u65f6\uff0c\u4f18\u5316\u5668\u8f6c\u800c\u4f1a\u4f7f\u7528\u4f4d\u56fe\u626b\u63cf\u3002<\/p>\n

      explain (costs off) select * from t where a <= 100;\n<\/code><\/pre>\n
                   QUERY PLAN            \n------------------------------------\n Bitmap Heap Scan on t\n   Recheck Cond: (a <= 100)\n   ->  Bitmap Index Scan on t_a_idx\n         Index Cond: (a <= 100)\n(4 rows)\n<\/code><\/pre>\n

      AM\u9996\u5148\u67e5\u8be2\u5230\u6240\u6709\u6ee1\u8db3\u6761\u4ef6\u7684TID(Bitmap Index Scan node)\uff0c\u5e76\u4e14\u5229\u7528\u8fd9\u4e9bTID\u6784\u5efa\u4f4d\u56fe\u3002\u4f7f\u7528\u8fd9\u4e2a\u4f4d\u56fe\u8bfb\u53d6\u8868\u4e2d\u7684\u884c\u6570\u636e(Bitmap Heap Scan)\uff0c\u8868\u4e2d\u7684\u6bcf\u4e2a\u9875\u9762\u6700\u591a\u53ea\u9700\u8981\u8bfb\u53d6\u4e00\u6b21\u3002<\/p>\n

      \u5728\u7b2c\u4e8c\u4e2a\u6b65\u9aa4\u4e2d\uff0c\u7d22\u5f15\u6761\u4ef6\u53ef\u80fd\u9700\u8981\u91cd\u65b0\u68c0\u67e5 (Recheck Cond)\u3002\u8fd9\u7531\u4e0b\u9762\u4e24\u4e2a\u539f\u56e0\u5bfc\u81f4\uff1a<\/p>\n

        \n
      • \u5982\u679c\u4f4d\u56fe\u4e2d\u7684\u6bcf\u4e00\u4f4d\u53ea\u5bf9\u5e94\u4e00\u884c\u6570\u636e\uff0c\u53ef\u80fd\u5bfc\u81f4\u4f4d\u56fe\u65e0\u6cd5\u5728\u5185\u5b58\u4e2d\u5bb9\u7eb3 (\u53d7\u9650\u4e8ework_mem\u53c2\u6570)\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f4d\u56fe\u4f1a\u81ea\u52a8\uff08\u65e0\u6cd5\u6839\u636e\u67e5\u8be2\u8ba1\u5212\u5224\u65ad\uff09\u88ab\u6709\u635f\u538b\u7f29\uff0c\u4f4d\u56fe\u4e2d\u7684\u6bcf\u4e00\u4f4d\u4f1a\u5bf9\u5e94\u4e00\u4e2a\u57fa\u8868\u7684\u6570\u636e\u9875\u9762\u3002\u8fd9\u79cd\u6709\u635f\u7684\u4f4d\u56fe\u5360\u7528\u7684\u5185\u5b58\u66f4\u5c11\uff0c\u4f46\u662f\u5f53\u8bfb\u53d6\u4e00\u4e2a\u57fa\u8868\u7684\u6570\u636e\u9875\u9762\u65f6\uff0c\u6211\u4eec\u9700\u8981\u91cd\u65b0\u68c0\u67e5\u9875\u9762\u4e2d\u7684\u6bcf\u4e00\u884c\u662f\u5426\u6ee1\u8db3\u6761\u4ef6\u3002\u672c\u4f8b\u4e2d\uff0c\u5b9e\u9645\u6267\u884c\u65f6\uff0c\u4f7f\u7528\u7684\u662f\u7cbe\u786e\u4f4d\u56fe\uff08\u6bcf\u4f4d\u5bf9\u5e94\u4e00\u884c\uff09\uff0cRecheck Cond\u4ecd\u7136\u663e\u793a\u5728\u8ba1\u5212\u4e2d\uff0c\u867d\u7136\u6267\u884c\u65f6\u5e76\u4e0d\u4f1a\u771f\u6b63\u7684\u91cd\u65b0\u68c0\u67e5\u3002<\/li>\n
      • \u67d0\u4e9bAM\u53ea\u80fd\u731c\u6d4b\u51fa\u67d0\u884c\u6570\u636e\u53ef\u80fd\u6ee1\u8db3\u6761\u4ef6\uff0c\u4f46\u662f\u4e0d\u80fd\u786e\u5b9a\u7ed3\u8bba\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7d22\u5f15\u5f15\u64ce\u6267\u884c\u65f6\u4e00\u5b9a\u4f1a\u91cd\u65b0\u68c0\u67e5\u3002\u672c\u4f8b\u4e0d\u5c5e\u4e8e\u8fd9\u79cd\u60c5\u51b5\u3002<\/li>\n<\/ul>\n

        \u5982\u679c\u6761\u4ef6\u6d89\u53ca\u591a\u4e2a\u5217\uff0c\u5e76\u4e14\u5728\u8fd9\u4e9b\u5217\u4e0a\u90fd\u6709\u7d22\u5f15\uff0c\u4f4d\u56fe\u626b\u63cf\u53ef\u4ee5\u540c\u65f6\u4f7f\u7528\u8fd9\u4e9b\u7d22\u5f15\uff08\u5982\u679c\u4f18\u5316\u5668\u8ba4\u4e3a\u8fd9\u6837\u66f4\u52a0\u9ad8\u6548\uff09\u3002\u5bf9\u6bcf\u4e2a\u7d22\u5f15\uff0c\u751f\u6210\u4e00\u4e2a\u4f4d\u56fe\uff0c\u7136\u540e\u5bf9\u8fd9\u4e9b\u4f4d\u56fe\u505aAND\u6216OR\u7684\u8fd0\u7b97\u3002<\/p>\n

        create index on t(b);\nanalyze t;\nexplain (costs off) select * from t where a <= 100 and b = 'a';\n<\/code><\/pre>\n
                            QUERY PLAN                    \n--------------------------------------------------\n Bitmap Heap Scan on t\n   Recheck Cond: ((a <= 100) AND (b = 'a'::text))\n   ->  BitmapAnd\n         ->  Bitmap Index Scan on t_a_idx\n               Index Cond: (a <= 100)\n         ->  Bitmap Index Scan on t_b_idx\n               Index Cond: (b = 'a'::text)\n(7 rows)\n<\/code><\/pre>\n

        \u4e0a\u9762\u7684\u4f8b\u5b50\u4e2dBitmapAnd\u8282\u70b9\u5bf9\u4e24\u4e2a\u4f4d\u56fe\u6309\u4f4d\u505a\u4e86AND\u64cd\u4f5c\u3002<\/p>\n

        \u4f4d\u56fe\u626b\u63cf\u53ef\u4ee5\u907f\u514d\u6765\u56de\u8df3\u9875\u7684\u95ee\u9898\u3002\u4f46\u662f\u5982\u679c\u6570\u636e\u5728\u8868\u4e2d\u5b58\u653e\u7684\u7269\u7406\u987a\u5e8f\u4e0e\u7d22\u5f15\u8bb0\u5f55\u7684\u5b58\u653e\u987a\u5e8f\u76f8\u540c\u5462\uff1f\u6b64\u65f6\u7d22\u5f15\u626b\u63cf\u662f\u4e0d\u662f\u4e5f\u53ef\u4ee5\u907f\u514d\u6765\u56de\u8df3\u9875\u7684\u95ee\u9898\uff1f\u6beb\u65e0\u7591\u95ee\uff0c\u6211\u4eec\u4e0d\u80fd\u5b8c\u5168\u4f9d\u8d56\u6570\u636e\u5728\u9875\u9762\u4e2d\u7684\u7269\u7406\u987a\u5e8f\u3002\u5982\u679c\u6570\u636e\u9700\u8981\u6392\u5e8f\uff0c\u6211\u4eec\u5fc5\u987b\u5728sql\u8bed\u53e5\u4e2d\u663e\u5f0f\u6307\u5b9aorder by\u5b50\u53e5\u3002\u4f46\u662f\uff0c\u6570\u636e\u5728\u7269\u7406\u5b58\u653e\u987a\u5e8f\u4e0a\u51e0\u4e4e\u6709\u5e8f\u7684\u573a\u666f\u786e\u5b9e\u5b58\u5728\u3002\u6bd4\u5982\uff0c\u6570\u636e\u6309\u6240\u9700\u7684\u987a\u5e8f\u63d2\u5165\uff0c\u5e76\u4e14\u63d2\u5165\u4e4b\u540e\u6ca1\u6709\u88ab\u4fee\u6539\uff0c\u6216\u6267\u884c\u8fc7cluster\u547d\u4ee4\u3002\u5728\u8fd9\u4e9b\u573a\u666f\u4e2d\uff0c\u6784\u9020\u4e00\u4e2a\u4f4d\u56fe\u662f\u591a\u4f59\u7684\u6b65\u9aa4\uff0c\u5e38\u89c4\u7684\u7d22\u5f15\u626b\u63cf\u5c31\u5df2\u7ecf\u5f88\u597d\u3002\u56e0\u6b64\uff0c\u5f53\u4f18\u5316\u5668\u9009\u62e9AM\u65f6\uff0c\u4f1a\u67e5\u8be2\u4e00\u4e2a\u4e13\u95e8\u7684\u7edf\u8ba1\u4fe1\u606f\u9879\uff0c\u5b83\u8868\u793a\u67d0\u5217\u4e2d\u6570\u636e\u884c\u7684\u7269\u7406\u987a\u5e8f\u548c\u903b\u8f91\u987a\u5e8f\u7684\u76f8\u5173\u6027\u3002<\/p>\n

        select attname, correlation from pg_stats where tablename = 't';\n<\/code><\/pre>\n
         attname | correlation\n---------+-------------\n b       |    0.533512\n c       |    0.942365\n a       | -0.00768816\n(3 rows)\n<\/code><\/pre>\n

        \u7edd\u5bf9\u503c\u8d8a\u63a5\u8fd1\u4e8e1\uff0c\u8868\u793a\u76f8\u5173\u6027\u8d8a\u5927\uff0c\u6bd4\u5982c\u5217\u3002\u76f8\u53cd\uff0c\u7edd\u5bf9\u503c\u8d8a\u63a5\u8fd10\uff0c\u8868\u793a\u76f8\u5173\u6027\u8d8a\u5c0f\uff0c\u6570\u636e\u7684\u5b58\u653e\u987a\u5e8f\u8d8a\u6df7\u4e71\u3002<\/p>\n

        2.1.3 \u987a\u5e8f\u626b\u63cf<\/h3>\n

        \u5f53\u9009\u62e9\u7387\u5f88\u9ad8\uff08\u6ee1\u8db3\u6761\u4ef6\u7684\u884c\u5f88\u591a\uff09\u65f6\uff0c\u4f18\u5316\u5668\u653e\u5f03\u7d22\u5f15\u626b\u63cf\uff0c\u8f6c\u800c\u53bb\u4f7f\u7528\u987a\u5e8f\u626b\u63cf\u7684\u51b3\u7b56\u662f\u6b63\u786e\u7684\u3002<\/p>\n

        explain (costs off) select * from t where a <= 40000;\n<\/code><\/pre>\n
               QUERY PLAN      \n------------------------\n Seq Scan on t\n   Filter: (a <= 40000)\n(2 rows)\n<\/code><\/pre>\n

        \u539f\u56e0\u662f\uff1a\u9009\u62e9\u7387\u8d8a\u4f4e\uff0c\u8d8a\u9002\u5408\u4f7f\u7528\u7d22\u5f15\u626b\u63cf\u3002\u968f\u7740\u6ee1\u8db3\u6761\u4ef6\u884c\u6570\u7684\u589e\u52a0\uff0c\u626b\u63cf\u7d22\u5f15\u9875\u9762\u7684\u4ee3\u4ef7\u8d8a\u6765\u8d8a\u5927\u3002<\/p>\n

        \u987a\u5e8f\u626b\u63cf\u6bd4\u968f\u673a\u626b\u63cf\u66f4\u5feb\uff0c\u8fd9\u4f7f\u5f97\u4ee3\u4ef7\u4f30\u7b97\u53d8\u5f97\u66f4\u52a0\u590d\u6742\u3002\u5bf9\u78c1\u76d8\u6765\u8bf4\uff0c\u66f4\u662f\u8fd9\u6837\uff0c\u78c1\u5934\u7684\u5bfb\u9053\u65f6\u95f4\u8fdc\u8fdc\u9ad8\u4e8e\u8bfb\u53d6\u6570\u636e\u7684\u65f6\u95f4\u3002\u8fd9\u79cd\u73b0\u8c61\u5728SSD\u4e0a\u4e0d\u660e\u663e\u3002PG\u5185\u6838\u8ba1\u7b97\u626b\u63cf\u4ee3\u4ef7\u65f6\uff0c\u4f1a\u8003\u8651\u4e24\u4e2a\u53c2\u6570\uff0cseq_page_cost\u548crandom_page_cost\uff0c\u8fd9\u4e24\u4e2a\u53c2\u6570\u4e0d\u4f46\u53ef\u4ee5\u5168\u5c40\u8bbe\u7f6e\uff0c\u8fd8\u53ef\u4ee5\u5728\u8868\u7a7a\u95f4\u7ea7\u522b\u8bbe\u7f6e\uff0c\u8fd9\u6837\u53ef\u4ee5\u9002\u5e94\u4e0d\u540c\u7684\u5b58\u50a8\u4ecb\u8d28\u3002<\/p>\n

        2.1.4 \u53c2\u6570\u5316\u8def\u5f84<\/h3>\n

        \u4e0a\u9762\u7684\u4f8b\u5b50\u90fd\u662f\u5355\u8868\u7684\u67e5\u8be2\u3002\u5f53\u4e24\u5f20\u8868join\u65f6\uff0c\u5982\u679c\u67d0\u4e2a\u8868\u5728\u8fde\u63a5\u6761\u4ef6\u4e0a\u6709\u7d22\u5f15\uff0c\u5219\u6709\u53ef\u80fd\u751f\u6210\u53c2\u6570\u5316\u7684\u8def\u5f84\u3002\u5b83\u7684\u8868\u73b0\u5f62\u5f0f\u662f\uff1ajoin\u7684\u7c7b\u578b\u4e3aNestloop\uff0c\u5185\u8868\u4f7f\u7528\u7d22\u5f15\uff0c\u5e76\u4e14\u7d22\u5f15\u4e0a\u6709\u7d22\u5f15\u6761\u4ef6\uff08\u800c\u4e0d\u662f\u8fc7\u6ee4\u6761\u4ef6\uff09\u3002\u5982\u4e0b\u6240\u793a\u3002<\/p>\n

        create table t1(a int, b int);\ncreate table t2(a int, b int);\ncreate index on t2(a);\n\nset enable_mergejoin=off;\nset enable_hashjoin=off;\nset enable_seqscan=off;\n\nexplain (costs off) select * from t1 join t2 on t1.a = t2.a;\n<\/code><\/pre>\n
                      QUERY PLAN               \n---------------------------------------\n Nested Loop\n   ->  Seq Scan on t1\n   ->  Index Scan using t2_a_idx on t2\n         Index Cond: (a = t1.a)\n(4 rows)\n<\/code><\/pre>\n

        \u8fd9\u79cdJoin\u7684\u4e3b\u8981\u6267\u884c\u6d41\u7a0b\u662f\uff1a<\/p>\n

          \n
        • Nestloop join\u7b97\u5b50\u4f9d\u6b21\u8bfb\u53d6t1\u4e2d\u7684\u6bcf\u884c\u6570\u636e\n
            \n
          • Nestloop join\u7b97\u5b50\u628at1\u4e2d\u6bcf\u884c\u6570\u636e\u7684t1.a\uff08\u6b64\u65f6t1.a\u662f\u4e00\u4e2a\u786e\u5b9a\u7684\u503c\uff0c\u53ef\u4ee5\u5f53\u4f5cconst\uff09\u901a\u8fc7\u53c2\u6570\u4f20\u9012\u7ed9\u5185\u8868Index Scan\u7b97\u5b50<\/li>\n
          • Index Scan\u7b97\u5b50\u4f7f\u7528t2.a=const\u4f5c\u4e3a\u6761\u4ef6\u5b8c\u6210\u7d22\u5f15\u626b\u63cf<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n

            2.2 Covering Indexes<\/h2>\n

            Covering indexes\uff0c\u6709\u7684\u8d44\u6599\u7ffb\u8bd1\u4e3a\u8986\u76d6\u7d22\u5f15\u3002\u6309\u89c4\u5b9a\uff0cAM\u7684\u4e3b\u8981\u4efb\u52a1\u7ed9\u7d22\u5f15\u5f15\u64ce\u8fd4\u56de\u7b26\u5408\u6761\u4ef6\u884c\u7684TID\uff0c\u7531\u7d22\u5f15\u5f15\u64ce\u6839\u636eTID\u53bb\u8868\u4e2d\u8bfb\u53d6\u8fd9\u4e9b\u884c\u7684\u6570\u636e\u3002\u5f53\u7d22\u5f15\u4e2d\u5df2\u7ecf\u5305\u542b\u4e86\u67e5\u8be2\u6240\u9700\u7684\u6240\u6709\u6570\u636e\u65f6\uff0c\u4f1a\u600e\u6837\u5462\uff1f\u8fd9\u79cd\u7d22\u5f15\u88ab\u79f0\u4f5cCovering\uff0c\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f18\u5316\u5668\u53ef\u4ee5\u9009\u62e9Index Only Scan\uff1a<\/p>\n

            vacuum t;\nexplain (costs off) select a from t where a < 100;\n<\/code><\/pre>\n
                         QUERY PLAN            \n------------------------------------\n Index Only Scan using t_a_idx on t\n   Index Cond: (a < 100)\n(2 rows)\n<\/code><\/pre>\n

            \u8fd9\u4e2a\u540d\u5b57\u5177\u6709\u4e00\u5b9a\u8ff7\u60d1\u6027\uff0c\u5b83\u53ef\u80fd\u8ba9\u4eba\u611f\u89c9AM\u53ef\u4ee5\u63d0\u4f9b\u6240\u6709\u7684\u6570\u636e\uff0c\u7d22\u5f15\u5f15\u64ce\u4e0d\u518d\u9700\u8981\u53bb\u8bbf\u95ee\u57fa\u8868\u3002\u4f46\u4e8b\u5b9e\u5e76\u4e0d\u5b8c\u5168\u662f\u8fd9\u6837\uff0c\u56e0\u4e3aPG\u4e2d\u7684\u7d22\u5f15\u6ca1\u6709\u4fdd\u5b58\u7528\u6765\u5224\u65ad\u53ef\u89c1\u6027\u7684\u4fe1\u606f\u3002\u56e0\u6b64\uff0cAM\u76f4\u63a5\u7ed9\u7d22\u5f15\u5f15\u64ce\u8fd4\u56de\u4e00\u4e2a\u6ee1\u8db3\u6761\u4ef6\u7684\u884c\u6570\u636e\uff0c\u800c\u4e0d\u5173\u5fc3\u5b83\u662f\u5426\u5bf9\u672c\u4e8b\u52a1\u53ef\u89c1\u3002<\/p>\n

            \u7136\u800c\uff0c\u5982\u679c\u7d22\u5f15\u5f15\u64ce\u6bcf\u6b21\u5224\u65ad\u884c\u7684\u53ef\u89c1\u6027\u90fd\u9700\u8981\u8bbf\u95ee\u57fa\u8868\u7684\u8bdd\uff0c\u90a3\u4e48Index Only Scan\u548cIndex Scan\u5c31\u522b\u65e0\u4e8c\u81f4\u3002<\/p>\n

            \u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cPG\u7ef4\u62a4\u4e86\u4e00\u4e2aVisibility Map\uff0cVacuum\u7ed9\u7b26\u5408\u4e0b\u9762\u8981\u6c42\u7684\u9875\u9762\u505a\u4e00\u4e2a\u6807\u8bb0\u3002\u8fd9\u4e9b\u9875\u9762\u4e2d\u7684\u6570\u636e\u5df2\u7ecf\u5f88\u4e45\u6ca1\u6709\u88ab\u66f4\u65b0\u8fc7\uff0c\u56e0\u6b64\u8fd9\u4e9b\u6570\u636e\u5bf9\u6240\u6709\u7684\u4e8b\u52a1\u90fd\u53ef\u89c1\uff0c\u65e0\u8bba\u4e8b\u52a1\u4f55\u65f6\u5f00\u59cb\uff0c\u65e0\u8bba\u9694\u79bb\u7ea7\u522b\u662f\u4ec0\u4e48\u3002\u5982\u679cAM\u8fd4\u56de\u7684TID\u6307\u5411\u8fd9\u4e9b\u9875\u9762\uff0c\u5219\u65e0\u9700\u518d\u5224\u65ad\u53ef\u89c1\u6027\u3002<\/p>\n

            \u56e0\u6b64\uff0c\u9002\u65f6\u7684Vacuum\u53ef\u4ee5\u63d0\u9ad8Covering Index\u7684\u6027\u80fd\u3002\u4f18\u5316\u5668\u4e5f\u4f1a\u8003\u8651Dead Tuple\u7684\u6570\u91cf\uff0c\u5f53\u53ef\u89c1\u6027\u5224\u65ad\u5f00\u9500\u592a\u5927\u65f6\uff0c\u4f1a\u653e\u5f03Index Only Scan\u3002<\/p>\n

            \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528EXPLAIN ANALYZE\u770b\u51fa\u56e0\u4e3a\u5224\u65ad\u53ef\u89c1\u6027\u800c\u88ab\u8feb\u8bbf\u95ee\u57fa\u8868\u7684\u6b21\u6570\uff1a<\/p>\n

            explain (analyze, costs off) select a from t where a < 100;\n<\/code><\/pre>\n
                                              QUERY PLAN                                  \n-------------------------------------------------------------------------------\n Index Only Scan using t_a_idx on t (actual time=0.025..0.036 rows=99 loops=1)\n   Index Cond: (a < 100)\n   Heap Fetches: 0\n Planning time: 0.092 ms\n Execution time: 0.059 ms\n(5 rows)\n<\/code><\/pre>\n

            \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6ca1\u6709\u53bb\u8bbf\u95ee\u8868 (Heap Fetches: 0)\uff0c\u56e0\u4e3a\u521a\u521a\u505a\u8fc7Vacuum\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u8bbf\u95ee\u6b21\u6570\u8d8a\u5c11\u8d8a\u597d\u3002<\/p>\n

            \u5e76\u975e\u6240\u6709\u7684\u7d22\u5f15\u90fd\u5b58\u50a8\u7d22\u5f15\u5217\u7684\u503c\u548cTID\u3002\u5982\u679cAM\u4e0d\u80fd\u8fd4\u56de\u7cbe\u786e\u7684\u5217\u503c\uff0c\u5219\u4e0d\u80fd\u7528\u4f5cIndex Only Scan\uff0c\u6bd4\u5982Hash\u7d22\u5f15\u3002\u5b83\u5c06\u5217\u503c\u8ba1\u7b97\u51fa\u4e00\u4e2aHash\u503c\u5b58\u653e\u5728\u7d22\u5f15\u4e2d\uff0cHash\u7684\u8fc7\u7a0b\u4e0d\u53ef\u9006\uff0c\u56e0\u6b64\u65e0\u6cd5\u83b7\u53d6\u539f\u59cb\u7684\u5217\u503c\u3002<\/p>\n

            PG 11 \u589e\u52a0\u4e86\u4e00\u4e2a\u65b0\u7279\u6027\uff1aINCLUDE-indexes\u3002\u5982\u679c\u4e00\u4e2a\u552f\u4e00\u7d22\u5f15\u7f3a\u5c11\u4e00\u4e9b\u5217\uff0c\u4f7f\u5f97\u5b83\u4e0d\u80fd\u6210\u4e3a\u4e00\u4e9b\u67e5\u8be2\u7684Covering Index\uff0c\u5e94\u8be5\u600e\u4e48\u529e\uff1f\u4f60\u4e0d\u80fd\u7b80\u5355\u7684\u628a\u8fd9\u4e9b\u5217\u52a0\u5230\u8fd9\u4e2a\u7d22\u5f15\u4e2d\uff0c\u56e0\u4e3a\u8fd9\u4f1a\u7834\u574f\u7d22\u5f15\u7684\u552f\u4e00\u6027\uff08\u5141\u8bb8\u5728\u52a0\u5217\u4e4b\u524d\u7684\u7d22\u5f15\u4e0a\u6709\u91cd\u590d\u503c\uff09\u3002\u8fd9\u4e2a\u7279\u6027\u5141\u8bb8\u589e\u52a0\u4e00\u4e9bNon-Key\u5217\uff0c\u8fd9\u4e9b\u5217\u4e0d\u4f1a\u5f71\u54cd\u7d22\u5f15\u7684\u552f\u4e00\u6027\uff0c\u4e0d\u80fd\u7528\u4f5c\u7d22\u5f15\u7684\u641c\u7d22\u6761\u4ef6\uff0c\u4f46\u662f\u53ef\u4ee5\u5728Index Only Scan\u4e2d\u88ab\u4f7f\u7528\u3002<\/p>\n

            2.3 NULL<\/h2>\n

            NULL\u503c\u5728\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e2d\u626e\u6f14\u7740\u91cd\u8981\u7684\u89d2\u8272\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u8868\u793a\u4e0d\u5b58\u5728\u6216\u672a\u77e5\u503c\u7684\u65b9\u5f0f\u3002<\/p>\n

            \u4f46\u662f\u8fd9\u4e2a\u7279\u6b8a\u503c\u9700\u8981\u88ab\u7279\u6b8a\u5904\u7406\u3002\u5e38\u89c4\u7684\u5e03\u5c14\u4ee3\u6570\u53d8\u6210\u4e86\u4e09\u5143\uff08\u771f\u3001\u5047\u3001NULL\uff09\uff1b\u6211\u4eec\u4e0d\u77e5\u9053NULL\u6bd4\u6b63\u5e38\u503c\u5927\u8fd8\u662f\u5c0f\uff08\u5bf9\u6392\u5e8f\u6765\u8bf4\uff0c\u8fd9\u9700\u8981\u7279\u6b8a\u7684\u8003\u8651\uff0cNULLS FIRST\u548cNULLS LAST\uff09\uff1b\u805a\u96c6\u51fd\u6570\u662f\u5426\u9700\u8981\u8003\u8651NULL\u503c\u4e5f\u5e76\u4e0d\u660e\u663e\uff1b\u4f18\u5316\u5668\u9700\u8981\u4e3aNULL\u503c\u4fdd\u5b58\u7279\u6b8a\u7684\u7edf\u8ba1\u4fe1\u606f\uff0c\u7b49\u7b49\u2026\u2026<\/p>\n

            \u4ece\u7d22\u5f15\u652f\u6301\u7684\u89d2\u5ea6\u8003\u8651\uff0c\u4e5f\u4e0d\u6e05\u695a\u662f\u5426\u5e94\u8be5\u7d22\u5f15\u8fd9\u4e9bNULL\u503c\u3002\u5982\u679c\u4e0d\u7d22\u5f15NULL\u503c\uff0c\u7d22\u5f15\u4f1a\u6bd4\u8f83\u7d27\u51d1\u3002\u5982\u679c\u7d22\u5f15NULL\u503c\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528\u7d22\u5f15\u56de\u7b54\u201cindexed-field IS [NOT] NULL\u201d\u8fd9\u79cd\u67e5\u8be2\uff0c\u800c\u4e14\u53ef\u4ee5\u5728\u4e0d\u6307\u5b9a\u4efb\u4f55\u6761\u4ef6\u65f6\u88ab\u5f53\u505aCovering Index\uff08\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7d22\u5f15\u5fc5\u987b\u8fd4\u56de\u8868\u4e2d\u6240\u6709\u7684\u6570\u636e\uff0c\u5305\u62ecNULLs\uff09\u3002<\/p>\n

            \u5bf9\u6bcf\u79cdAM\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u81ea\u884c\u51b3\u7b56\u662f\u5426\u7d22\u5f15NULL\u3002\u5927\u591a\u6570AM\u4e2d\uff0cNULL\u503c\u4f1a\u88ab\u7d22\u5f15\u3002<\/p>\n

            2.4 \u591a\u5217\u7d22\u5f15<\/h2>\n

            \u4e3a\u4e86\u652f\u6301\u4f7f\u7528\u5305\u542b\u591a\u4e2a\u5217\u7684\u6761\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u5217\u7d22\u5f15\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u8868\u4e2d\u7684\u4e24\u4e2a\u5217\u5efa\u7acb\u4e00\u4e2a\u7d22\u5f15\uff1a<\/p>\n

            create index on t(a,b);\nanalyze t;\n<\/code><\/pre>\n

            \u4f18\u5316\u5668\u66f4\u53ef\u80fd\u503e\u5411\u4e8e\u4f7f\u7528\u8fd9\u4e2a\u7d22\u5f15\uff0c\u800c\u4e0d\u662f\u4f7f\u7528\u4e24\u4e2a\u4f4d\u56fe\uff0c\u56e0\u4e3a\u5728\u8fd9\u4e00\u4e2a\u7d22\u5f15\u4e2d\u5c31\u53ef\u4ee5\u5f97\u5230\u6240\u9700\u7684TID\uff0c\u65e0\u9700\u5176\u5b83\u64cd\u4f5c\u3002<\/p>\n

            explain (costs off) select * from t where a <= 100 and b = 'a';\n<\/code><\/pre>\n
                               QUERY PLAN                  \n------------------------------------------------\n Index Scan using t_a_b_idx on t\n   Index Cond: ((a <= 100) AND (b = 'a'::text))\n(2 rows)\n<\/code><\/pre>\n

            \u5982\u679c\u4e00\u4e2a\u6761\u4ef6\u4e2d\u4ec5\u4ec5\u4f7f\u7528\u4e86\u4e00\u4e2a\u591a\u5217\u7d22\u5f15\u4e2d\u7684\u90e8\u5206\u5217\uff0c\u5e76\u4e14\u4f7f\u7528\u4e86\u4ece\u7b2c\u4e00\u4e2a\u7d22\u5f15\u5217\u5f00\u59cb\u7684\u67d0\u4e9b\u5217\uff0c\u8fd9\u4e2a\u591a\u5217\u7d22\u5f15\u4e5f\u53ef\u4ee5\u88ab\u67e5\u8be2\u4f7f\u7528\u3002<\/p>\n

            explain (costs off) select * from t where a <= 100;\n<\/code><\/pre>\n
                          QUERY PLAN              \n--------------------------------------\n Bitmap Heap Scan on t\n   Recheck Cond: (a <= 100)\n   ->  Bitmap Index Scan on t_a_b_idx\n         Index Cond: (a <= 100)\n(4 rows)\n<\/code><\/pre>\n

            \u901a\u5e38\u6765\u8bb2\uff0c\u5982\u679c\u6761\u4ef6\u6ca1\u6709\u4f7f\u7528\u7b2c\u4e00\u4e2a\u7d22\u5f15\u5217\uff0c\u8fd9\u4e2a\u7d22\u5f15\u4e0d\u4f1a\u88ab\u4f7f\u7528\u3002\u4f46\u662f\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\uff0c\u4f18\u5316\u5668\u53ef\u80fd\u4f1a\u8ba4\u4e3a\u4f7f\u7528\u7d22\u5f15\u4f1a\u6bd4\u5168\u8868\u626b\u63cf\u66f4\u52a0\u9ad8\u6548\u3002\u6211\u4eec\u5c06\u5728\u8bb2\u89e3Btree\u7d22\u5f15\u65f6\u5c55\u5f00\u8fd9\u4e2a\u8bdd\u9898\u3002<\/p>\n

            \u4e0d\u662f\u6240\u6709\u7684AM\u90fd\u652f\u6301\u591a\u5217\u7d22\u5f15\u3002<\/p>\n

            2.5 \u8868\u8fbe\u5f0f\u7d22\u5f15<\/h2>\n

            \u6211\u4eec\u63d0\u5230\u8fc7\uff0c\u641c\u7d22\u6761\u4ef6\u5fc5\u987b\u8981\u7b26\u5408indexed-field operator expression\u7684\u5f62\u5f0f\u3002\u5728\u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u7d22\u5f15\u4e0d\u80fd\u88ab\u4f7f\u7528\uff0c\u56e0\u4e3a\u5b83\u4f7f\u7528\u4e86\u4e00\u4e2a\u5305\u542b\u7d22\u5f15\u5217\u7684\u8868\u8fbe\u5f0f\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u4f7f\u7528\u5217\u540d\u672c\u8eab\u3002<\/p>\n

            explain (costs off) select * from t where lower(b) = 'a';\n<\/code><\/pre>\n
                            QUERY PLAN                \n------------------------------------------\n Seq Scan on t\n   Filter: (lower((b)::text) = 'a'::text)\n(2 rows)\n<\/code><\/pre>\n

            \u5bf9\u8fd9\u4e2a\u8bed\u53e5\u6765\u8bf4\uff0c\u5f88\u5bb9\u6613\u5c06\u5b83\u6539\u5199\u6210\u7b26\u5408\u4f7f\u7528\u7d22\u5f15\u6761\u4ef6\u7684\u8bed\u53e5\u3002\u4f46\u662f\u5f53\u67d0\u4e9b\u67e5\u8be2\u4e0d\u80fd\u88ab\u6539\u5199\u65f6\uff0c\u8868\u8fbe\u5f0f\u7d22\u5f15\uff08\u51fd\u6570\u7d22\u5f15\uff09\u5c31\u53ef\u4ee5\u88ab\u6d3e\u4e0a\u7528\u573a\u3002<\/p>\n

            create index on t(lower(b));\nanalyze t;\nexplain (costs off) select * from t where lower(b) = 'a';\n<\/code><\/pre>\n
                                 QUERY PLAN                    \n----------------------------------------------------\n Bitmap Heap Scan on t\n   Recheck Cond: (lower((b)::text) = 'a'::text)\n   ->  Bitmap Index Scan on t_lower_idx\n         Index Cond: (lower((b)::text) = 'a'::text)\n(4 rows)\n<\/code><\/pre>\n

            \u51fd\u6570\u7d22\u5f15\u4e0d\u662f\u5efa\u7acb\u8868\u7684\u67d0\u5217\u4e0a\uff0c\u800c\u662f\u5efa\u7acb\u5728\u4efb\u610f\u8868\u8fbe\u5f0f\u4e0a\u3002\u4f18\u5316\u5668\u4f1a\u5bf9\u7b26\u5408indexed-expression operator expression\u5f62\u5f0f\u7684\u6761\u4ef6\u5c1d\u8bd5\u4f7f\u7528\u8fd9\u79cd\u7d22\u5f15\u3002\u5982\u679c\u8fd9\u4e2a\u8868\u8fbe\u5f0f\u7684\u8ba1\u7b97\u975e\u5e38\u8017\u8d39\u8d44\u6e90\uff0c\u66f4\u65b0\u7d22\u5f15\u65f6\u5c31\u9700\u8981\u6d88\u8017\u76f8\u5f53\u53ef\u89c2\u7684\u8d44\u6e90\u3002<\/p>\n

            \u8bf7\u6ce8\u610f\uff0c\u8868\u8fbe\u5f0f\u7d22\u5f15\u7684\u7edf\u8ba1\u4fe1\u606f\u4f1a\u88ab\u5355\u72ec\u7684\u6536\u96c6\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u7d22\u5f15\u7684\u540d\u5b57\u4ecepg_stats\u89c6\u56fe\u4e2d\u67e5\u8be2\uff1a<\/p>\n

            \\d t\n\n       Table \"public.t\"\n Column |  Type   | Modifiers\n--------+---------+-----------\n a      | integer |\n b      | text    |\n c      | boolean |\nIndexes:\n    \"t_a_b_idx\" btree (a, b)\n    \"t_a_idx\" btree (a)\n    \"t_b_idx\" btree (b)\n    \"t_lower_idx\" btree (lower(b))\n<\/code><\/pre>\n
            select * from pg_stats where tablename = 't_lower_idx';\n<\/code><\/pre>\n

            \u5982\u679c\u6709\u5fc5\u8981\uff0c\u4e5f\u53ef\u4ee5\u6539\u53d8\u76f4\u65b9\u56fe\u4e2dbucket\u7684\u6570\u91cf\uff0c\u5c31\u50cf\u64cd\u4f5c\u666e\u901a\u6570\u636e\u7c7b\u578b\u4e00\u6837\uff08\u6ce8\u610f\u5217\u540d\u53ef\u80fd\u56e0\u7d22\u5f15\u8868\u8fbe\u5f0f\u7684\u4e0d\u540c\u800c\u4e0d\u540c\uff09\uff1a<\/p>\n

            \\d t_lower_idx\n\n Index \"public.t_lower_idx\"\n Column | Type | Definition\n--------+------+------------\n lower  | text | lower(b)\nbtree, for table \"public.t\"\n<\/code><\/pre>\n
            alter index t_lower_idx alter column \"lower\" set statistics 69;\n<\/code><\/pre>\n

            PG 11\u53ef\u4ee5\u4f7f\u7528\u4e00\u79cd\u66f4\u52a0\u6e05\u6670\u7684\u65b9\u5f0f\u63a7\u5236\u7d22\u5f15\u7684\u7edf\u8ba1\u4fe1\u606f\uff0c\u8bed\u6cd5\u4e3aALTER INDEX … SET STATISTICS\u3002<\/p>\n

            2.6 \u90e8\u5206\u7d22\u5f15<\/h2>\n

            \u6709\u65f6\u6211\u4eec\u4ec5\u4ec5\u9700\u8981\u5bf9\u8868\u4e2d\u90e8\u5206\u6570\u636e\u5efa\u7acb\u7d22\u5f15\u3002\u8fd9\u5728\u6570\u636e\u5206\u5e03\u4e25\u91cd\u4e0d\u5747\u7684\u60c5\u51b5\u4e0b\u6bd4\u8f83\u6709\u7528\uff1a\u4f7f\u7528\u7d22\u5f15\u67e5\u627e\u51fa\u73b0\u9891\u7387\u8f83\u4f4e\u7684\u503c\uff0c\u4f7f\u7528\u5168\u8868\u626b\u63cf\u67e5\u627e\u51fa\u73b0\u9891\u7387\u8f83\u9ad8\u7684\u503c\u3002<\/p>\n

            \u6211\u4eec\u53ef\u4ee5\u5728c\u5217\u4e0a\u5efa\u7acb\u4e00\u4e2a\u7d22\u5f15\uff1a<\/p>\n

            create index on t(c);\nanalyze t;\nexplain (costs off) select * from t where c;\n<\/code><\/pre>\n
                      QUERY PLAN          \n-------------------------------\n Index Scan using t_c_idx on t\n   Index Cond: (c = true)\n   Filter: c\n(3 rows)\n<\/code><\/pre>\n
            explain (costs off) select * from t where not c;\n<\/code><\/pre>\n
                QUERY PLAN    \n-------------------\n Seq Scan on t\n   Filter: (NOT c)\n(2 rows)\n<\/code><\/pre>\n

            \u7d22\u5f15\u5360\u7528\u4e86276\u4e2a\u9875\u9762<\/p>\n

            select relpages from pg_class where relname='t_c_idx';\n<\/code><\/pre>\n
             relpages\n----------\n      276\n(1 row)\n<\/code><\/pre>\n

            \u4f46\u662f\u56e0\u4e3ac\u5217\u53ea\u67091%\u7684\u884c\u4e3atrue\uff0c99%\u7684\u7d22\u5f15\u5e76\u6ca1\u6709\u88ab\u4f7f\u7528\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u5efa\u7acb\u4e00\u4e2a\u90e8\u5206\u7d22\u5f15\uff1a<\/p>\n

            create index on t(c) where c;\nanalyze t;\n<\/code><\/pre>\n

            \u7d22\u5f15\u5360\u7528\u7684\u9875\u9762\u6570\u51cf\u5c11\u52305\u4e2a\u3002<\/p>\n

            select relpages from pg_class where relname='t_c_idx1';\n<\/code><\/pre>\n
             relpages\n----------\n        5\n(1 row)\n<\/code><\/pre>\n

            \u6709\u65f6\u5019\uff0c\u7a7a\u95f4\u5360\u7528\u548c\u6027\u80fd\u53ef\u80fd\u90fd\u5f88\u91cd\u8981\u3002<\/p>\n

            2.7 \u6392\u5e8f<\/h2>\n

            \u5982\u679c\u4e00\u4e2aAM\u53ef\u4ee5\u6309\u7167\u67d0\u79cd\u987a\u5e8f\u8fd4\u56deTID\uff0c\u5c31\u53ef\u4ee5\u4e3a\u4f18\u5316\u5668\u63d0\u4f9b\u66f4\u591a\u7684\u9009\u62e9\u6765\u4f18\u5316\u8fd9\u4e2a\u67e5\u8be2\u3002<\/p>\n

            \u6211\u4eec\u53ef\u4ee5\u5148\u626b\u63cf\u5168\u8868\uff0c\u7136\u540e\u6392\u5e8f\uff1a<\/p>\n

            set enable_indexscan=off;\n\nexplain (costs off) select * from t order by a;\n<\/code><\/pre>\n
                 QUERY PLAN      \n---------------------\n Sort\n   Sort Key: a\n   ->  Seq Scan on t\n(3 rows)\n<\/code><\/pre>\n

            \u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5df2\u7ecf\u6309\u9700\u6392\u5e8f\u7684\u7d22\u5f15\u76f4\u63a5\u8bfb\u53d6\u6570\u636e\uff1a<\/p>\n

            set enable_indexscan=on;\nexplain (costs off) select * from t order by a;\n<\/code><\/pre>\n
                      QUERY PLAN          \n-------------------------------\n Index Scan using t_a_idx on t\n(1 row)\n<\/code><\/pre>\n

            \u5728\u6240\u6709\u7684AM\u4e2d\uff0c\u53ea\u6709Btree\u7d22\u5f15\u53ef\u4ee5\u8fd4\u56de\u6709\u5e8f\u7684\u6570\u636e\uff0c\u6240\u4ee5\u6211\u4eec\u5c06\u5728\u4ecb\u7ecdBtree\u7d22\u5f15\u65f6\u5bf9\u6b64\u95ee\u9898\u8fdb\u884c\u66f4\u8be6\u7ec6\u7684\u4ecb\u7ecd\u3002<\/p>\n

            2.8 \u5e76\u884c\u521b\u5efa<\/h2>\n

            \u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5efa\u7acb\u7d22\u5f15\u9700\u8981\u5bf9\u8868\u52a0Share\u9501\u3002\u8fd9\u4e2a\u9501\u5141\u8bb8\u5176\u5b83\u4e8b\u52a1\u4ece\u8868\u4e2d\u8bfb\u53d6\u6570\u636e\uff0c\u4f46\u662f\u5728\u7d22\u5f15\u521b\u5efa\u671f\u95f4\u7981\u6b62\u5176\u5b83\u4e8b\u52a1\u5411\u8868\u4e2d\u63d2\u5165\u6570\u636e\u3002<\/p>\n

            \u6211\u4eec\u53ef\u4ee5\u5728\u7ed9\u8868t\u5efa\u7acb\u7d22\u5f15\u671f\u95f4\uff0c\u5728\u53e6\u4e00\u4e2asession\u8fdb\u884c\u4e0b\u9762\u7684\u67e5\u8be2\uff1a<\/p>\n

            select mode, granted from pg_locks where relation = 't'::regclass;\n<\/code><\/pre>\n
               mode    | granted\n-----------+---------\n ShareLock | t\n(1 row)\n<\/code><\/pre>\n

            \u5982\u679c\u8fd9\u4e2a\u8868\u7279\u522b\u5927\uff0c\u5e76\u4e14\u9700\u8981\u7ecf\u5e38\u8fdb\u884c\u589e\u5220\u6539\uff0c\u4e8b\u52a1\u957f\u65f6\u95f4\u6301\u6709Share\u9501\u4f1a\u53d8\u5f97\u4e0d\u53ef\u63a5\u53d7\uff0c\u56e0\u4e3a\u5199\u4e8b\u52a1\u5fc5\u987b\u957f\u65f6\u95f4\u7b49\u5f85\uff0c\u76f4\u5230Share\u9501\u88ab\u91ca\u653e\u3002<\/p>\n

            \u8fd9\u79cd\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5e76\u884c\u521b\u5efa\u7d22\u5f15\u7684\u529f\u80fd\uff1a<\/p>\n

            create index concurrently on t(a);\n<\/code><\/pre>\n

            \u8fd9\u4e2a\u547d\u4ee4\u5bf9\u8868\u52a0SHARE UPDATE EXCLUSIV\u9501\uff0c\u5b83\u5141\u8bb8\u8868\u88ab\u8bfb\u53d6\u548c\u66f4\u65b0\uff08\u4ec5\u4ec5\u7981\u6b62\u6539\u53d8\u8868\u5b9a\u4e49\u3001Vacuum\u3001Analyze\u548c\u540c\u65f6\u5728\u8fd9\u4e2a\u8868\u4e0a\u201c\u5e76\u884c\u521b\u5efa\u201d\u5176\u5b83\u7d22\u5f15\u3002\u8bf7\u53c2\u8003PG\u76844\u53f7\u9501\uff09\u3002<\/p>\n

            \u7136\u800c\uff0c\u8fd9\u4e5f\u6709\u4e0d\u5229\u7684\u4e00\u9762\u3002\u9996\u5148\uff0c\u8fd9\u4e2a\u7d22\u5f15\u4f1a\u521b\u5efa\u7684\u6bd4\u8f83\u6162\u3002\u56e0\u4e3a\u8fd9\u4e2a\u8fc7\u7a0b\u9700\u8981\uff1a<\/p>\n

              \n
            • \u4e24\u6b21\u5168\u8868\u626b\u63cf\uff0c\u800c\u4e0d\u662f\u4e00\u904d<\/li>\n
            • \u7b49\u5f85\u7d22\u5f15\u521b\u5efa\u671f\u95f4\u7684\u5199\u4e8b\u52a1\u7ed3\u675f\u3002<\/li>\n<\/ul>\n

              \u5176\u6b21\uff0c\u5e76\u884c\u521b\u5efa\u6267\u884c\u671f\u95f4\uff0c\u53ef\u80fd\u4f1a\u53d1\u751f\u6b7b\u9501\uff0c\u6216\u8005\u8fdd\u53cd\u4e00\u81f4\u6027\u7ea6\u675f\u3002\u7136\u800c\uff0c\u7d22\u5f15\u8fd8\u662f\u4f1a\u88ab\u521b\u5efa\u51fa\u6765\uff0c\u867d\u7136\u8fd9\u6837\u7684\u7d22\u5f15\u4e0d\u80fd\u7528\u3002\u8fd9\u79cd\u7d22\u5f15\u5fc5\u987b\u88ab\u624b\u5de5\u5220\u9664\u6216\u91cd\u5efa\u3002\u5728psql\u7684\d\u547d\u4ee4\u7684\u8f93\u51fa\u4e2d\uff0c\u8fd9\u4e9b\u4e0d\u80fd\u7528\u7684\u7d22\u5f15\u4f1a\u88ab\u6807\u8bb0\u4e3aINVALID\uff0c\u4e0b\u9762\u7684sql\u8bed\u53e5\u53ef\u4ee5\u67e5\u8be2\u5230\u8fd9\u79cd\u7d22\u5f15\u7684\u5b8c\u6574\u5217\u8868\uff1a<\/p>\n

              select indexrelid::regclass index_name, indrelid::regclass table_name\nfrom pg_index where not indisvalid;\n<\/code><\/pre>\n
               index_name | table_name\n------------+------------\n t_a_idx    | t\n(1 row)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

              \u6458\u8981\uff1a<\/b>PostgreSQL\u652f\u6301\u591a\u79cd\u7d22\u5f15\u7c7b\u578b\uff0c\u6bcf\u79cd\u7d22\u5f15\u7c7b\u578b\u88ab\u79f0\u4e3a\u4e00\u79cd\u5b58\u53d6\u65b9\u6cd5\uff08Access Method\uff0c\u7b80\u79f0AM\uff09\u3002\u4e3a\u4e86\u7edf\u4e00\u8fd9\u4e9bAM\uff0cPG\u5728AM\u5c42\u4e4b\u4e0a\u5b9e\u73b0\u4e86\u4e00\u4e2a\u901a\u7528\u7d22\u5f15\u5f15\u64ce\u3002\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u901a\u7528\u7d22\u5f15\u5f15\u64ce\u548cAM\u7684\u8d23\u4efb\u5212\u5206\u3001\u901a\u7528\u7d22\u5f15\u5f15\u64ce\u7684\u529f\u80fd\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/posts\/108"}],"collection":[{"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":69,"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":620,"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/posts\/108\/revisions\/620"}],"wp:attachment":[{"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}