{"id":330,"date":"2020-10-01T06:00:40","date_gmt":"2020-09-30T22:00:40","guid":{"rendered":"https:\/\/www.mengqingzhong.com\/?p=330"},"modified":"2024-01-14T11:38:31","modified_gmt":"2024-01-14T03:38:31","slug":"postgresql-index-spgist-6","status":"publish","type":"post","link":"https:\/\/www.mengqingzhong.com\/2020\/10\/01\/postgresql-index-spgist-6\/","title":{"rendered":"PostgreSQL\u7d22\u5f15(6) \u2013 SP-GiST"},"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\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 \u5728\u524d\u9762\u51e0\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u8ba8\u8bba\u4e86\u901a\u7528\u7d22\u5f15\u5f15\u64ce\u3001AM\u7684\u63a5\u53e3\u548c\u4e09\u79cdAM\uff08Hash\u7d22\u5f15\u3001B-tree\u7d22\u5f15\u3001GiST\u7d22\u5f15\uff09\u3002\u8fd9\u7bc7\u6587\u7ae0\u5c06\u4ecb\u7ecdSP-GiST\u7d22\u5f15\u3002<\/p>\n \u9996\u5148\uff0c\u4ecb\u7ecd\u4e00\u4e2a\u8fd9\u4e2a\u540d\u5b57\u3002GiST\u6697\u793a\u7740\u5b83\u548cGiST\u7d22\u5f15\u6709\u4e00\u4e9b\u7c7b\u4f3c\u3002\u5b83\u4eec\u90fd\u662f\u901a\u7528\u641c\u7d22\u6811\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6846\u67b6\u7528\u6765\u521b\u5efa\u4e0d\u540c\u7684\u7d22\u5f15\u7c7b\u578b\u3002<\/p>\n SP\u8868\u793a\u7a7a\u95f4\u5206\u5272\uff08space partitioning\uff09\u3002\u8fd9\u91cc\u7684\u7a7a\u95f4\uff0c\u5c31\u662f\u6211\u4eec\u5e73\u65f6\u6240\u6210\u7684\u7a7a\u95f4\uff0c\u4f8b\u5982\uff0c\u5b83\u53ef\u4ee5\u662f\u4e00\u4e2a\u4e8c\u7ef4\u7684\u5e73\u9762\u3002\u4f46\u662f\uff0c\u6211\u4eec\u5c06\u4f1a\u770b\u5230\u5b83\u53ef\u4ee5\u8868\u793a\u4efb\u610f\u641c\u7d22\u7a7a\u95f4\u3002<\/p>\n SP-GiST\u9002\u5408\u53ef\u4ee5\u88ab\u9012\u5f52\u5206\u5272\u6210\u4e92\u4e0d\u76f8\u4ea4\u533a\u57df\u7684\u7a7a\u95f4\u3002\u8fd9\u7c7b\u7a7a\u95f4\u5305\u62ec\uff1a\u56db\u53c9\u6811\uff08quadtrees\uff09\u3001K-D tree\u3001\u57fa\u6570\u6811\uff08radix trees\uff09\u7b49\u3002<\/p>\n SP-GiST\u7684\u601d\u60f3\u5c31\u662f\u628a\u503c\u57df\u5212\u5206\u6210\u4e92\u4e0d\u76f8\u4ea4\u7684\u5b50\u57df\uff0c\u5e76\u4e14\u8fd9\u4e9b\u5b50\u57df\u53ef\u4ee5\u7ee7\u7eed\u88ab\u5206\u5272\u3002\u4f7f\u7528\u8fd9\u6837\u7684\u5206\u5272\u65b9\u5f0f\uff0c\u4f1a\u5bfc\u81f4\u6811\u4e0d\u5e73\u8861\uff08\u4e0d\u50cfB-tree\u548c\u5e38\u89c4\u7684GiST\u7d22\u5f15\uff09\u3002<\/p>\n \u4e0d\u76f8\u4ea4\u7684\u7279\u70b9\uff0c\u4f7f\u5f97\u7b97\u6cd5\u5728\u63d2\u5165\u548c\u641c\u7d22\u65f6\u7684\u51b3\u7b56\u8fc7\u7a0b\u53d8\u5f97\u7b80\u5355\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u8fd9\u4e5f\u5bfc\u81f4\u6811\u7684\u5e73\u8861\u5ea6\u964d\u4f4e\u3002\u4f8b\u5982\uff0c\u56db\u53c9\u6811\u7684\u4e00\u4e2a\u8282\u70b9\u901a\u5e38\u5305\u542b4\u4e2a\u5b50\u8282\u70b9\uff08\u4e0d\u50cfB-tree\u90a3\u6837\u53ef\u4ee5\u5305\u542b\u51e0\u767e\u4e2a\uff09\u5e76\u4e14\u6811\u6bd4\u8f83\u6df1\u3002\u8fd9\u79cd\u6811\u7684\u7ed3\u6784\u6bd4\u8f83\u9002\u5408\u5185\u5b58\uff0c\u4f46\u662f\u6811\u88ab\u5b58\u5728\u78c1\u76d8\u4e0a\uff0c\u56e0\u6b64\uff0c\u4e3a\u4e86\u51cf\u5c11IO\u64cd\u4f5c\uff0c\u8282\u70b9\u9700\u8981\u88ab\u6253\u5305\u5b58\u5728\u9875\u9762\u4e2d\u3002\u6253\u5305\u5176\u5b9e\u5f88\u96be\u9ad8\u6548\u7684\u5b8c\u6210\u3002\u800c\u4e14\uff0c\u56e0\u4e3a\u4e0d\u540c\u8282\u70b9\u7684\u6df1\u5ea6\u4e0d\u540c\uff0c\u6240\u4ee5\u5728\u6811\u4e2d\u67e5\u627e\u4e0d\u540c\u7684\u503c\uff0c\u4ee3\u4ef7\u5e76\u4e0d\u76f8\u540c\u3002<\/p>\n \u548cGiST\u4e00\u6837\uff0cSP-GiST\u4e5f\u5904\u7406\u4e86\u5e95\u5c42\u7684\u4efb\u52a1\uff08\u5e76\u53d1\u63a7\u5236\u3001\u65e5\u5fd7\u3001\u641c\u7d22\u6846\u67b6\uff09\uff0c\u5e76\u4e14\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u63a5\u53e3\u4e3a\u6dfb\u52a0\u65b0\u7684\u6570\u636e\u7c7b\u578b\u548c\u65b0\u7684\u5206\u5272\u7b97\u6cd5\u63d0\u4f9b\u652f\u6301\u3002<\/p>\n SP-GiST\u7684\u975e\u53f6\u5b50\u8282\u70b9\u5b58\u50a8\u4e86\u6307\u5411\u5b69\u5b50\u8282\u70b9\u7684\u6307\u9488\uff1b\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u6307\u9488\u6307\u5b9a\u4e00\u4e2a\u6807\u7b7e\u3002\u975e\u53f6\u5b50\u8282\u70b9\u53ef\u4ee5\u5b58\u50a8\u4e00\u4e2a\u79f0\u4e3a\u524d\u7f00\u7684\u503c\u3002\u4e8b\u5b9e\u4e0a\uff0c\u8fd9\u4e2a\u503c\u4e0d\u4e00\u5b9a\u662f\u4e00\u4e2a\u524d\u7f00\uff1b\u5b83\u53ef\u4ee5\u662f\u4efb\u610f\u4e00\u4e2a\u6240\u6709\u5b69\u5b50\u8282\u70b9\u90fd\u6ee1\u8db3\u7684\u8c13\u8bcd\u3002<\/p>\n SP-GiST\u7684\u53f6\u5b50\u8282\u70b9\u5b58\u50a8\u4e86\u7d22\u5f15\u7c7b\u578b\u7684\u4e00\u4e2a\u503c\uff0c\u548c\u4e00\u4e2a\u6307\u5411\u57fa\u8868\u7684TID\u3002\u7d22\u5f15\u6570\u636e\u672c\u8eab\uff08\u641c\u7d22key\uff09\u53ef\u4ee5\u88ab\u7528\u4f5c\u8fd9\u4e2a\u503c\uff0c\u4f46\u8fd9\u4e0d\u662f\u5fc5\u987b\u7684\uff1a\u53ef\u4ee5\u7528\u4e00\u4e2a\u66f4\u77ed\u7684\u503c\u3002<\/p>\n \u800c\u4e14\uff0c\u53f6\u5b50\u8282\u70b9\u53ef\u4ee5\u88ab\u5206\u7ec4\u6210list\u3002\u6240\u4ee5\uff0c\u975e\u53f6\u5b50\u8282\u70b9\u4e0d\u4f46\u53ef\u4ee5\u6307\u5411\u4e00\u4e2a\u503c\uff0c\u800c\u4e14\u53ef\u4ee5\u6307\u5411\u4e00\u4e2a\u94fe\u8868\u3002<\/p>\n \u6ce8\u610f\uff0c\u53f6\u5b50\u8282\u70b9\u4e2d\u7684\u524d\u7f00\u3001\u6807\u7b7e\u3001\u503c\u90fd\u6709\u4ed6\u4eec\u4e92\u76f8\u72ec\u7acb\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n \u548cGiST\u7d22\u5f15\u4e00\u6837\uff0c\u5b9a\u4e49\u67e5\u8be2\u7684\u4e3b\u8981\u51fd\u6570\u5c31\u662f\u4e00\u81f4\u6027\u51fd\u6570\u3002\u5904\u7406\u6bcf\u4e2a\u8282\u70b9\u65f6\u90fd\u4f1a\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u8fd9\u4e2a\u51fd\u6570\u8fd4\u56de\u4e0e\u641c\u7d22\u8c13\u8bcd\uff08indexed-field operator expression\uff09\u4e00\u81f4\u7684\u5b69\u5b50\u8282\u70b9\u7684\u96c6\u5408\u3002\u5bf9\u53f6\u5b50\u8282\u70b9\u6765\u8bf4\uff0c\u8fd9\u4e2a\u4e00\u81f4\u6027\u51fd\u6570\u51b3\u5b9a\u8282\u70b9\u4e2d\u7684\u7d22\u5f15\u503c\u662f\u5426\u6ee1\u8db3\u641c\u7d22\u6761\u4ef6\u3002<\/p>\n \u67e5\u8be2\u4ece\u6839\u8282\u70b9\u5f00\u59cb\u3002\u4e00\u81f4\u6027\u51fd\u6570\u53ef\u4ee5\u627e\u51fa\u9700\u8981\u8bbf\u95ee\u7684\u5b69\u5b50\u8282\u70b9\u3002\u5bf9\u627e\u5230\u7684\u8282\u70b9\u91cd\u590d\u8fd9\u4e2a\u8fc7\u7a0b\u3002\u4f7f\u7528\u6df1\u5ea6\u4f18\u5148\u641c\u7d22\u3002<\/p>\n \u5728\u7269\u7406\u5c42\u9762\uff0c\u7d22\u5f15\u8282\u70b9\u88ab\u6253\u5305\u5230\u9875\u9762\u4e2d\uff0c\u4f7f\u5f97IO\u66f4\u9ad8\u6548\u3002\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u4e00\u4e2a\u9875\u9762\u8981\u4e48\u5b58\u653e\u975e\u53f6\u5b50\u8282\u70b9\uff0c\u8981\u4e48\u5b58\u50a8\u53f6\u5b50\u8282\u70b9\uff0c\u4e0d\u80fd\u540c\u65f6\u5b58\u50a8\u4e8c\u8005\u3002<\/p>\n \u56db\u53c9\u6811\u7528\u6765\u7d22\u5f15\u5e73\u9762\u4e0a\u7684\u70b9\u3002\u5176\u4e2d\u4e00\u4e2a\u65b9\u6cd5\u5c31\u662f\uff1a\u4f7f\u7528\u4e00\u4e2a\u4e2d\u5fc3\u70b9\u628a\u533a\u57df\u5212\u5206\u62104\u4e2a\u5b50\u533a\u57df\uff08\u8c61\u9650\uff09\u3002\u6811\u4e2d\u5206\u652f\u7684\u6df1\u5ea6\u4e0e\u76f8\u5e94\u8c61\u9650\u4e2d\u70b9\u7684\u5bc6\u5ea6\u76f8\u5173\u3002<\/p>\n Demo\u6570\u636e\u5e93\u52a0\u4e0aopenflights.org\u7684\u6570\u636e\u540e\uff0c\u753b\u51fa\u7684\u56fe\u7247\u5982\u4e0b\u3002\u540e\u6587\u4e2d\uff0c\u6211\u4eec\u628a\u7ecf\u5ea6\u548c\u7ef4\u5ea6\u6362\u6210point\u3002<\/p>\n <\/a> <\/a> <\/a> \u6211\u4eec\u7ee7\u7eed\u8ba8\u8bba\u4e0a\u7bc7\u6587\u7ae0\u4e2d\u90a3\u4e2a\u7b80\u5355\u793a\u4f8b\u7684\u4e00\u4e9b\u7ec6\u8282\u3002\u5212\u5206\u60c5\u51b5\u53ef\u80fd\u662f\u8fd9\u6837\uff1a<\/p>\n <\/a><\/p>\n \u8c61\u9650\u7684\u7f16\u53f7\u5728\u5de6\u8fb9\u7684\u56fe\u7247\u4e2d\u3002\u4e3a\u4e86\u76f4\u89c2\uff0c\u6211\u4eec\u6309\u7167\u76f8\u540c\u7684\u987a\u5e8f\u4ece\u5de6\u5230\u53f3\u4f9d\u6b21\u5b58\u653e\u5b69\u5b50\u8282\u70b9\u3002\u7d22\u5f15\u53ef\u80fd\u50cf\u4e0b\u56fe\u4e00\u6837\u5b58\u653e\u3002\u6bcf\u4e2a\u975e\u53f6\u5b50\u8282\u70b9\u6700\u591a\u5b58\u653e4\u4e2a\u5b69\u5b50\u8282\u70b9\u3002\u6bcf\u4e2a\u6307\u9488\u53ef\u4ee5\u7528\u8c61\u9650\u7684\u7f16\u53f7\u8868\u793a\u3002\u5728\u771f\u6b63\u7684\u5b9e\u73b0\u4e2d\u5e76\u4e0d\u9700\u8981\u6807\u7b7e\uff0c\u76f4\u63a5\u4f7f\u7528\u6570\u7ec4\u7684\u4e0b\u6807\u66f4\u52a0\u65b9\u4fbf\u3002<\/p>\n <\/a><\/p>\n \u5728\u8c61\u9650\u8fb9\u754c\u4e0a\u7684\u70b9\u5c5e\u4e8e\u7f16\u53f7\u8f83\u5c0f\u7684\u8c61\u9650\u3002<\/p>\n \u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u9ed8\u8ba4\u4f7f\u7528quad_point_ops\u64cd\u4f5c\u7b26\u7c7b\uff0c\u5b83\u5305\u542b\u4e0b\u5217\u64cd\u4f5c\u7b26\uff1a<\/p>\n \u4f8b\u5982\uff0c\u6211\u4eec\u7814\u7a76select * from points where p >^ point ‘(2,7)’\u7684\u6267\u884c\u8fc7\u7a0b\uff08\u627e\u51fa\u5728(2,7)\u4e0a\u9762\u7684\u70b9\uff09\u3002<\/p>\n <\/a><\/p>\n \u6211\u4eec\u4ece\u6839\u8282\u70b9\u5f00\u59cb\uff0c\u4f7f\u7528\u4e00\u81f4\u6027\u51fd\u6570\u786e\u5b9a\u9700\u8981\u641c\u7d22\u54ea\u4e9b\u5b69\u5b50\u8282\u70b9\u3002\u5bf9\u64cd\u4f5c\u7b26>^\u6765\u8bf4\uff0c\u8fd9\u4e2a\u51fd\u6570\u628a(2,7)\u548c\u4e2d\u5fc3\u70b9(4,4)\u6bd4\u8f83\uff0c\u9009\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u7b2c\u4e00\u3001\u56db\u8c61\u9650\u3002<\/p>\n \u5bf9\u4e0e\u7b2c\u4e00\u8c61\u9650\u5173\u8054\u7684\u8282\u70b9\uff0c\u6211\u4eec\u7ee7\u7eed\u4f7f\u7528\u4e00\u81f4\u6027\u51fd\u6570\u3002\u4e2d\u5fc3\u70b9\u662f(6,6)\uff0c\u63a5\u7740\u518d\u53bb\u904d\u5386\u7b2c\u4e00\u3001\u56db\u8c61\u9650\u3002<\/p>\n <\/a><\/p>\n \u53f6\u5b50\u8282\u70b9\u4e2d\u7684(8,6) and (7,8)\u5c5e\u4e8e\u7b2c\u4e00\u8c61\u9650\uff0c\u53ea\u6709(7,8)\u6ee1\u8db3\u6761\u4ef6\u3002\u7b2c\u56db\u8c61\u9650\u4ee3\u8868\u7684\u5185\u5bb9\u4e3a\u7a7a\u3002<\/p>\n \u975e\u53f6\u5b50\u8282\u70b9(4,4)\u6307\u5411\u7684\u7b2c\u56db\u8c61\u9650\u4e5f\u4e3a\u7a7a\uff0c\u56e0\u6b64\u641c\u7d22\u8fc7\u7a0b\u7ed3\u675f\u3002<\/p>\n \u6211\u4eec\u53ef\u4ee5\u7ee7\u7eed\u4f7f\u7528gevel\u63d2\u4ef6\u63a2\u7d22SP-GiST\u7684\u5185\u90e8\u7ed3\u6784\u3002\u4e0d\u5e78\u7684\u662fgevel\u63d2\u4ef6\u4e0e\u6700\u65b0\u7684PG\u4e0d\u517c\u5bb9\u3002<\/p>\n \u4f8b\u5982\uff0cdemo\u6570\u636e\u5e93\u4e2d\u5c55\u793a\u4e16\u754c\u5730\u56fe\u7684\u4f8b\u5b50\u3002<\/p>\n \u7d22\u5f15\u7684\u4e00\u4e9b\u7edf\u8ba1\u4fe1\u606f\uff1a<\/p>\n \u7136\u540e\uff0c\u8f93\u51fa\u6811\u672c\u8eab\uff1a<\/p>\n spgist_print\u6ca1\u6709\u8f93\u51fa\u6240\u6709\u53f6\u5b50\u8282\u70b9\u7684\u503c\uff0c\u53ea\u8f93\u51fa\u4e86\u5217\u8868\u4e2d\u7684\u7b2c\u4e00\u4e2a\u3002\u56e0\u6b64\uff0c\u53ea\u8f93\u51fa\u4e86\u6811\u7684\u7ed3\u6784\uff0c\u800c\u4e0d\u662f\u6240\u6709\u7684\u5185\u5bb9\u3002<\/p>\n \u4ecd\u7136\u4f7f\u7528\u4e0a\u9762\u7684\u793a\u4f8b\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u53e6\u5916\u4e00\u79cd\u65b9\u5f0f\u5206\u5272\u7a7a\u95f4\u3002<\/p>\n \u8ba9\u6211\u4eec\u4f7f\u7528\u7b2c\u4e00\u4e2a\u88ab\u7d22\u5f15\u7684\u70b9\u6c34\u5e73\u753b\u4e00\u6761\u76f4\u7ebf\u3002\u5b83\u5c06\u5e73\u9762\u5206\u6210\u4e0a\u4e0b\u4e24\u4e2a\u90e8\u5206\u3002\u7b2c\u4e8c\u70b9\u5c5e\u4e8e\u5176\u4e2d\u4e00\u4e2a\u90e8\u5206\uff0c\u4f7f\u7528\u8fd9\u4e2a\u70b9\u5782\u76f4\u753b\u4e00\u6761\u76f4\u7ebf\uff0c\u53c8\u53ef\u4ee5\u5c06\u8fd9\u4e2a\u90e8\u5206\u5212\u5206\u6210\u5de6\u53f3\u4e24\u90e8\u5206\u3002\u4f9d\u6b64\u7c7b\u63a8\uff0c\u7ee7\u7eed\u4f7f\u7528\u540e\u9762\u7684\u70b9\u6a2a\u7ad6\u753b\u7ebf\u3002<\/p>\n \u6240\u6709\u5185\u90e8\u8282\u70b9\u90fd\u5305\u542b2\u4e2a\u5b69\u5b50\u8282\u70b9\u3002\u4e24\u4e2a\u6307\u9488\u8981\u4e48\u90fd\u6307\u5411\u4e0b\u4e00\u5c42\u7684\u53f6\u5b50\u8282\u70b9\uff0c\u8981\u4e48\u90fd\u6307\u5411\u5b69\u5b50\u8282\u70b9\u3002<\/p>\n \u8fd9\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5212\u5206k\u7ef4\u7a7a\u95f4\uff0c\u56e0\u6b64\u4e5f\u88ab\u79f0\u4e3ak-D tree\u3002<\/p>\n \u5c55\u793a\u673a\u573a\u793a\u4f8b\u7684\u5212\u5206\u8fc7\u7a0b\uff1a<\/p>\n <\/a> <\/a>1. \u7ed3\u6784<\/h1>\n
2. \u793a\u4f8b\uff1a\u56db\u53c9\u6811<\/h1>\n
\n\u9996\u5148\uff0c\u628a\u5e73\u9762\u5212\u5206\u62104\u4e2a\u8c61\u9650<\/p>\n
\n\u7136\u540e\uff0c\u5bf9\u6bcf\u4e2a\u8c61\u9650\u7ee7\u7eed\u5212\u5206<\/p>\n
\n\u76f4\u5230\u5f97\u5230\u6700\u540e\u7684\u5212\u5206<\/p>\ncreate table points(p point);\ninsert into points(p) values\n (point '(1,1)'), (point '(3,2)'), (point '(6,3)'),\n (point '(5,5)'), (point '(7,8)'), (point '(8,6)');\ncreate index points_quad_idx on points using spgist(p);\n<\/code><\/pre>\n
select amop.amopopr::regoperator, amop.amopstrategy\nfrom pg_opclass opc, pg_opfamily opf, pg_am am, pg_amop amop\nwhere opc.opcname = 'quad_point_ops'\nand opf.oid = opc.opcfamily\nand am.oid = opf.opfmethod\nand amop.amopfamily = opc.opcfamily\nand am.amname = 'spgist'\nand amop.amoplefttype = opc.opcintype;\n<\/code><\/pre>\n
amopopr | amopstrategy\n-----------------+--------------\n <<(point,point) | 1 strictly left\n >>(point,point) | 5 strictly right\n ~=(point,point) | 6 coincides\n <^(point,point) | 10 strictly below\n >^(point,point) | 11 strictly above\n <@(point,box) | 8 contained in rectangle\n(6 rows)\n<\/code><\/pre>\n
set enable_seqscan = off;\nexplain (costs off) select * from points where p >^ point '(2,7)';\n<\/code><\/pre>\n
QUERY PLAN \n------------------------------------------------\n Index Only Scan using points_quad_idx on points\n Index Cond: (p >^ '(2,7)'::point)\n(2 rows)\n<\/code><\/pre>\n
\u5185\u90e8\u7ed3\u6784<\/h2>\n
create index airports_coordinates_quad_idx on airports_ml using spgist(coordinates);\n<\/code><\/pre>\n
select * from spgist_stats('airports_coordinates_quad_idx');\n<\/code><\/pre>\n
spgist_stats \n----------------------------------\n totalPages: 33 +\n deletedPages: 0 +\n innerPages: 3 +\n leafPages: 30 +\n emptyPages: 2 +\n usedSpace: 201.53 kbytes+\n usedInnerSpace: 2.17 kbytes +\n usedLeafSpace: 199.36 kbytes+\n freeSpace: 61.44 kbytes +\n fillRatio: 76.64% +\n leafTuples: 5993 +\n innerTuples: 37 +\n innerAllTheSame: 0 +\n leafPlaceholders: 725 +\n innerPlaceholders: 0 +\n leafRedirects: 0 +\n innerRedirects: 0\n(1 row)\n<\/code><\/pre>\n
select tid, n, level, tid_ptr, prefix, leaf_value\nfrom spgist_print('airports_coordinates_quad_idx') as t(\n tid tid,\n allthesame bool,\n n int,\n level int,\n tid_ptr tid,\n prefix point, -- prefix type\n node_label int, -- label type (unused here)\n leaf_value point -- list value type\n)\norder by tid, n;\n<\/code><\/pre>\n
tid | n | level | tid_ptr | prefix | leaf_value\n---------+---+-------+---------+------------------+------------------\n (1,1) | 0 | 1 | (5,3) | (-10.220,53.588) |\n (1,1) | 1 | 1 | (5,2) | (-10.220,53.588) |\n (1,1) | 2 | 1 | (5,1) | (-10.220,53.588) |\n (1,1) | 3 | 1 | (5,14) | (-10.220,53.588) |\n (3,68) | | 3 | | | (86.107,55.270)\n (3,70) | | 3 | | | (129.771,62.093)\n (3,85) | | 4 | | | (57.684,-20.430)\n (3,122) | | 4 | | | (107.438,51.808)\n (3,154) | | 3 | | | (-51.678,64.191)\n (5,1) | 0 | 2 | (24,27) | (-88.680,48.638) |\n (5,1) | 1 | 2 | (5,7) | (-88.680,48.638) |\n ...\n<\/code><\/pre>\n
3. \u793a\u4f8b\uff1ak-dimensional trees<\/h1>\n
\n\u9996\u5148\u5c06\u5e73\u9762\u5212\u5206\u6210\u4e0a\u4e0b\u4e24\u90e8\u5206<\/p>\n
\n\u628a\u6bcf\u4e2a\u90e8\u5206\u7ee7\u7eed\u5212\u5206\u6210\u5de6\u53f3\u4e24\u90e8\u5206<\/p>\n