{"id":523,"date":"2020-10-01T02:02:24","date_gmt":"2020-09-30T18:02:24","guid":{"rendered":"https:\/\/www.mengqingzhong.com\/?p=523"},"modified":"2024-01-14T11:38:30","modified_gmt":"2024-01-14T03:38:30","slug":"postgresql-index-demodb-bookings","status":"publish","type":"post","link":"https:\/\/www.mengqingzhong.com\/2020\/10\/01\/postgresql-index-demodb-bookings\/","title":{"rendered":"PG\u7d22\u5f15\u7cfb\u5217\u6587\u7ae0\u4e2d\u7684Demo\u6570\u636e\u5e93"},"content":{"rendered":"

\u5728Egor Rogov\u4ecb\u7ecd\u7d22\u5f15\u7684\u7cfb\u5217\u6587\u7ae0\u4e2d\uff0cEgor Rogov\u4f7f\u7528\u4e86\u4e00\u4e2ademo\u6570\u636e\u5e93<\/a>\u3002\u5b83\u6e90\u81eaPostgres Pro\uff0c\u4e3b\u8981\u4f9b\u6570\u636e\u5e93\u7684\u4f7f\u7528\u8005\u5b66\u4e60\u4f7f\u7528\uff0c\u5c31\u50cfOracle\u4e2d\u81ea\u5e26\u7684demo\u6570\u636e\u5e93\u4e00\u6837\u3002\u4e3a\u4e86\u4f7f\u8bfb\u8005\u66f4\u597d\u7684\u7406\u89e3\u672c\u7cfb\u5217\u7684\u540e\u7eed\u6587\u7ae0\uff0c\u8bd1\u8005\u5728\u672c\u6587\u4e2d\u5bf9\u8fd9\u4e2ademo\u6570\u636e\u5e93\u505a\u4e00\u4e9b\u7b80\u8981\u7684\u4ecb\u7ecd\u3002\u8bfb\u8005\u53ef\u4ee5\u81ea\u884c\u67e5\u9605Postres Pro\u7684\u6587\u6863\uff0c\u4e86\u89e3\u66f4\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n

\u8fd9\u4e2ademo\u6570\u636e\u5e93\u6a21\u62df\u4e86\u4e00\u4e2a\u4fc4\u7f57\u65af\u822a\u7a7a\u9886\u57df\u7684\u7cfb\u7edf\u3002\u968f\u7740Postgres Pro\u7248\u672c\u7684\u66f4\u65b0\uff0c\u8fd9\u4e2ademo\u6570\u636e\u5e93\u4e5f\u4f1a\u66f4\u65b0\uff08\u65b0\u65e7\u7248\u672c\u5927\u540c\u5c0f\u5f02\uff09\uff0c\u672c\u7cfb\u5217\u4f7f\u7528\u7684\u7248\u672c\u4e2d\uff0c\u5305\u62ec8\u5f20\u8868\uff0c\u548c\u4e00\u4e9b\u89c6\u56fe\u3002\u8bfb\u8005\u53ef\u4ee5\u4ece\u8fd9\u91cc\u4e0b\u8f7d<\/a>\u8fd9\u4e2ademo\u6570\u636e\u5e93\u4e2d\u6700\u65b0\u7248\uff08\u8bd1\u8005\u6ca1\u6709\u5728\u5b98\u7f51\u627e\u5230\u8001\u7248\u672c\u7684\u6570\u636e\uff09\u7684\u6570\u636e\uff08\u5305\u62ec\u5efa\u8868\u8bed\u53e5\uff09\u3002<\/p>\n

Schema<\/h1>\n

\u8fd9\u4e2a\u7cfb\u7edf\u7684schema\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

\"\"<\/a><\/p>\n

\u6bcf\u5f20\u8868\u7684\u8be6\u7ec6\u5b9a\u4e49\u53ef\u4ee5\u5728\u8fd9\u91cc\u67e5\u5230:https:\/\/postgrespro.com\/docs\/postgrespro\/9.6\/apjs04<\/a><\/p>\n

\u4e0b\u9762\u662f\u8bd1\u8005\u5bfc\u5165\u65b0\u7248\u672c\u6570\u636e\u540e\uff0c\u5f97\u5230\u7684schema\u3002<\/p>\n

demo=# \\d\n                  List of relations\n  Schema  |         Name          |   Type   | Owner \n----------+-----------------------+----------+-------\n bookings | aircrafts             | view     | meng\n bookings | aircrafts_data        | table    | meng\n bookings | airports              | view     | meng\n bookings | airports_data         | table    | meng\n bookings | boarding_passes       | table    | meng\n bookings | bookings              | table    | meng\n bookings | flights               | table    | meng\n bookings | flights_flight_id_seq | sequence | meng\n bookings | flights_v             | view     | meng\n bookings | routes                | view     | meng\n bookings | seats                 | table    | meng\n bookings | ticket_flights        | table    | meng\n bookings | tickets               | table    | meng\n(13 rows)\n<\/code><\/pre>\n

\u6666\u6da9\u7684\u5b57\u6bb5<\/h1>\n

\u8868\u4e2d\u5927\u90e8\u5206\u5b57\u6bb5\u90fd\u6bd4\u8f83\u5bb9\u6613\u7406\u89e3\uff0c\u4e0b\u9762\u4ecb\u7ecd\u51e0\u4e2a\u6666\u6da9\u7684\u5b57\u6bb5\u3002<\/p>\n

fare_conditions<\/strong><\/p>\n

fare_conditions\u8868\u793a\u8231\u4f4d\uff0c\u5171\u6709Comfort\u3001Business\u3001Economy\u4e09\u79cd\u7c7b\u578b<\/p>\n

demo=# select fare_conditions,count(*) from seats group by fare_conditions;\n fare_conditions | count \n-----------------+-------\n Business        |   152\n Comfort         |    48\n Economy         |  1139\n(3 rows)\n<\/code><\/pre>\n

aircraft_code\u3001model\u548crange<\/strong><\/p>\n

aircrafts\u8868\u4e2d\u5305\u62ec\u6240\u6709\u7684\u673a\u578b\u3002aircraft_code\u662fIATA\u4e3a\u8fd9\u4e2a\u673a\u578b\u5206\u914d\u7684\u4ee3\u7801\uff0c\u53ef\u4ee5\u4ece\u76f8\u5173\u7f51\u7ad9\u67e5\u8be2\u5230\u3002model\u8868\u793a\u673a\u578b\u3002range\u8868\u793a\u7eed\u822a\u91cc\u7a0b\u3002<\/p>\n

demo=# select * from aircrafts          limit 10;\n aircraft_code |        model        | range \n---------------+---------------------+-------\n 773           | Boeing 777-300      | 11100\n 763           | Boeing 767-300      |  7900\n SU9           | Sukhoi Superjet-100 |  3000\n 320           | Airbus A320-200     |  5700\n 321           | Airbus A321-200     |  5600\n 319           | Airbus A319-100     |  6700\n 733           | Boeing 737-300      |  4200\n CN1           | Cessna 208 Caravan  |  1200\n CR2           | Bombardier CRJ-200  |  2700\n(9 rows)\n\n<\/code><\/pre>\n

\u793a\u4f8b\u6570\u636e<\/h1>\n

\u4e0b\u9762\u5217\u51fa\u5176\u5b83\u6bcf\u5f20\u8868\u4e2d\u7684\u4e00\u4e9b\u6570\u636e\u3002<\/p>\n

demo=# select * from airports           limit 10;\n airport_code |           airport_name            |       city        |               coordinates               |      timezone      \n--------------+-----------------------------------+-------------------+-----------------------------------------+--------------------\n YKS          | Yakutsk Airport                   | Yakutsk           | (129.77099609375,62.093299865722656)    | Asia\/Yakutsk\n MJZ          | Mirny Airport                     | Mirnyj            | (114.03900146484375,62.534698486328125) | Asia\/Yakutsk\n KHV          | Khabarovsk-Novy Airport           | Khabarovsk        | (135.18800354004,48.52799987793)        | Asia\/Vladivostok\n PKC          | Yelizovo Airport                  | Petropavlovsk     | (158.45399475097656,53.16790008544922)  | Asia\/Kamchatka\n UUS          | Yuzhno-Sakhalinsk Airport         | Yuzhno-Sakhalinsk | (142.71800231933594,46.88869857788086)  | Asia\/Sakhalin\n VVO          | Vladivostok International Airport | Vladivostok       | (132.1479949951172,43.39899826049805)   | Asia\/Vladivostok\n LED          | Pulkovo Airport                   | St. Petersburg    | (30.262500762939453,59.80030059814453)  | Europe\/Moscow\n KGD          | Khrabrovo Airport                 | Kaliningrad       | (20.592599868774414,54.88999938964844)  | Europe\/Kaliningrad\n KEJ          | Kemerovo Airport                  | Kemorovo          | (86.1072006225586,55.27009963989258)    | Asia\/Novokuznetsk\n CEK          | Chelyabinsk Balandino Airport     | Chelyabinsk       | (61.5033,55.305801)                     | Asia\/Yekaterinburg\n(10 rows)\n\ndemo=# select * from boarding_passes    limit 10;\n   ticket_no   | flight_id | boarding_no | seat_no \n---------------+-----------+-------------+---------\n 0005435212351 |     30625 |           1 | 2D\n 0005435212386 |     30625 |           2 | 3G\n 0005435212381 |     30625 |           3 | 4H\n 0005432211370 |     30625 |           4 | 5D\n 0005435212357 |     30625 |           5 | 11A\n 0005435212360 |     30625 |           6 | 11E\n 0005435212393 |     30625 |           7 | 11H\n 0005435212374 |     30625 |           8 | 12E\n 0005435212365 |     30625 |           9 | 13D\n 0005435212378 |     30625 |          10 | 14H\n(10 rows)\n\ndemo=# select * from bookings           limit 10;\n book_ref |       book_date        | total_amount \n----------+------------------------+--------------\n 00000F   | 2017-07-05 08:12:00+08 |    265700.00\n 000012   | 2017-07-14 14:02:00+08 |     37900.00\n 000068   | 2017-08-15 19:27:00+08 |     18100.00\n 000181   | 2017-08-10 18:28:00+08 |    131800.00\n 0002D8   | 2017-08-08 02:40:00+08 |     23600.00\n 0002DB   | 2017-07-29 11:30:00+08 |    101500.00\n 0002E0   | 2017-07-11 21:09:00+08 |     89600.00\n 0002F3   | 2017-07-10 10:31:00+08 |     69600.00\n 00034E   | 2017-08-04 21:52:00+08 |     73300.00\n 000352   | 2017-07-06 07:02:00+08 |    109500.00\n(10 rows)\n\n-- flight_no\u8868\u793a\u822a\u73ed\u53f7\uff0c(flight_no,scheduled_departure)\u662fflights\u8868\u7684\u81ea\u7136\u4e3b\u952e\uff0c\u4e3a\u4e86\u5176\u5b83\u8868\u5f15\u7528\u65b9\u4fbf\uff0c\u4f7f\u7528flight_id\u4f5c\u4e3a\u4e3b\u952e\u3002\ndemo=# select * from flights            limit 10;\n flight_id | flight_no |  scheduled_departure   |   scheduled_arrival    | departure_airport | arrival_airport |  status   | aircraft_code | actual_departure | actual_arrival \n-----------+-----------+------------------------+------------------------+-------------------+-----------------+-----------+---------------+------------------+----------------\n      1185 | PG0134    | 2017-09-10 14:50:00+08 | 2017-09-10 19:55:00+08 | DME               | BTK             | Scheduled | 319           |                  | \n      3979 | PG0052    | 2017-08-25 19:50:00+08 | 2017-08-25 22:35:00+08 | VKO               | HMA             | Scheduled | CR2           |                  | \n      4739 | PG0561    | 2017-09-05 17:30:00+08 | 2017-09-05 19:15:00+08 | VKO               | AER             | Scheduled | 763           |                  | \n      5502 | PG0529    | 2017-09-12 14:50:00+08 | 2017-09-12 16:20:00+08 | SVO               | UFA             | Scheduled | 763           |                  | \n      6938 | PG0461    | 2017-09-04 17:25:00+08 | 2017-09-04 18:20:00+08 | SVO               | ULV             | Scheduled | SU9           |                  | \n      7784 | PG0667    | 2017-09-10 20:00:00+08 | 2017-09-10 22:30:00+08 | SVO               | KRO             | Scheduled | CR2           |                  | \n      9478 | PG0360    | 2017-08-28 14:00:00+08 | 2017-08-28 16:35:00+08 | LED               | REN             | Scheduled | CR2           |                  | \n     11085 | PG0569    | 2017-08-24 20:05:00+08 | 2017-08-24 21:10:00+08 | SVX               | SCW             | Scheduled | 733           |                  | \n     11847 | PG0498    | 2017-09-12 15:15:00+08 | 2017-09-12 19:55:00+08 | KZN               | IKT             | Scheduled | 319           |                  | \n     12012 | PG0621    | 2017-08-26 21:05:00+08 | 2017-08-26 22:00:00+08 | KZN               | MQF             | Scheduled | CR2           |                  | \n(10 rows)\n\ndemo=# select * from seats              limit 10;\n aircraft_code | seat_no | fare_conditions \n---------------+---------+-----------------\n 319           | 2A      | Business\n 319           | 2C      | Business\n 319           | 2D      | Business\n 319           | 2F      | Business\n 319           | 3A      | Business\n 319           | 3C      | Business\n 319           | 3D      | Business\n 319           | 3F      | Business\n 319           | 4A      | Business\n 319           | 4C      | Business\n(10 rows)\n\n-- \u4e00\u5f20\u673a\u7968\u53ef\u80fd\u5bf9\u5e94\u591a\u4e2a\u73ed\u6b21\uff0c\u53ef\u80fd\u56e0\u4e3a\u8f6c\u673a\uff0c\u4e5f\u53ef\u80fd\u56e0\u4e3a\u662f\u5f80\u8fd4\u673a\u7968\u3002\ndemo=# select * from ticket_flights     limit 10;\n   ticket_no   | flight_id | fare_conditions |  amount  \n---------------+-----------+-----------------+----------\n 0005432159776 |     30625 | Business        | 42100.00\n 0005435212351 |     30625 | Business        | 42100.00\n 0005435212386 |     30625 | Business        | 42100.00\n 0005435212381 |     30625 | Business        | 42100.00\n 0005432211370 |     30625 | Business        | 42100.00\n 0005435212357 |     30625 | Comfort         | 23900.00\n 0005435212360 |     30625 | Comfort         | 23900.00\n 0005435212393 |     30625 | Comfort         | 23900.00\n 0005435212374 |     30625 | Comfort         | 23900.00\n 0005435212365 |     30625 | Comfort         | 23900.00\n(10 rows)\n\ndemo=# select * from tickets            limit 10;\n   ticket_no   | book_ref | passenger_id |   passenger_name    |                                   contact_data                                   \n---------------+----------+--------------+---------------------+----------------------------------------------------------------------------------\n 0005432000987 | 06B046   | 8149 604011  | VALERIY TIKHONOV    | {\"phone\": \"+70127117011\"}\n 0005432000988 | 06B046   | 8499 420203  | EVGENIYA ALEKSEEVA  | {\"phone\": \"+70378089255\"}\n 0005432000989 | E170C3   | 1011 752484  | ARTUR GERASIMOV     | {\"phone\": \"+70760429203\"}\n 0005432000990 | E170C3   | 4849 400049  | ALINA VOLKOVA       | {\"email\": \"volkova.alina_03101973@postgrespro.ru\", \"phone\": \"+70582584031\"}\n 0005432000991 | F313DD   | 6615 976589  | MAKSIM ZHUKOV       | {\"email\": \"m-zhukov061972@postgrespro.ru\", \"phone\": \"+70149562185\"}\n 0005432000992 | F313DD   | 2021 652719  | NIKOLAY EGOROV      | {\"phone\": \"+70791452932\"}\n 0005432000993 | F313DD   | 0817 363231  | TATYANA KUZNECOVA   | {\"email\": \"kuznecova-t-011961@postgrespro.ru\", \"phone\": \"+70400736223\"}\n 0005432000994 | CCC5CB   | 2883 989356  | IRINA ANTONOVA      | {\"email\": \"antonova.irina04121972@postgrespro.ru\", \"phone\": \"+70844502960\"}\n 0005432000995 | CCC5CB   | 3097 995546  | VALENTINA KUZNECOVA | {\"email\": \"kuznecova.valentina10101976@postgrespro.ru\", \"phone\": \"+70268080457\"}\n 0005432000996 | 1FB1E4   | 6866 920231  | POLINA ZHURAVLEVA   | {\"phone\": \"+70639918455\"}\n(10 rows)\n\ndemo=# \n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

\u5728Egor Rogov\u4ecb\u7ecd\u7d22\u5f15\u7684\u7cfb\u5217\u6587\u7ae0\u4e2d\uff0cEgor Rogov\u4f7f\u7528\u4e86\u4e00\u4e2ademo\u6570\u636e\u5e93\u3002\u5b83\u6e90\u81eaPostgres Pro\uff0c\u4e3b\u8981\u4f9b\u6570\u636e\u5e93\u7684\u4f7f\u7528\u8005\u5b66\u4e60\u4f7f\u7528\uff0c\u5c31\u50cfOracle\u4e2d\u81ea\u5e26\u7684demo\u6570\u636e\u5e93\u4e00\u6837\u3002\u4e3a\u4e86\u4f7f\u8bfb\u8005\u66f4\u597d\u7684\u7406\u89e3\u672c\u7cfb\u5217\u7684\u540e\u7eed\u6587\u7ae0\uff0c\u8bd1\u8005\u5728\u672c\u6587\u4e2d\u5bf9\u8fd9\u4e2ademo\u6570\u636e\u5e93\u505a\u4e00\u4e9b\u7b80\u8981\u7684\u4ecb\u7ecd\u3002\u8bfb\u8005\u53ef\u4ee5\u81ea\u884c\u67e5\u9605Postres Pro\u7684\u6587\u6863\uff0c\u4e86\u89e3\u66f4\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/posts\/523"}],"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=523"}],"version-history":[{"count":2,"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/posts\/523\/revisions"}],"predecessor-version":[{"id":548,"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/posts\/523\/revisions\/548"}],"wp:attachment":[{"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/media?parent=523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/categories?post=523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mengqingzhong.com\/wp-json\/wp\/v2\/tags?post=523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}