PostgreSQL ????????
???????????? ???????[ 2014/3/6 9:18:37 ] ????????????? ??? ??? PostgreSQL
????????????????????
??????PostgreSQL?У?????????????????????????????(REINDEX INDEX)?????б?????????B-Tree???????????Щ?????????????????????????????????Щ????????????????????????????????????????д????????????????????????o?????????????????????????????á???????????????£???????????????????????????????????????????????????????????ü?????????????????Ч???????????????????????????????Σ???
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????汻?????????????????????????????IOЧ??????????????
#1. ???????????в???????6??????????????SQL??佫????????????????????
postgres=# SELECT relname?? pg_relation_size(oid)/1024 || 'K' AS size FROM pg_class WHERE relkind='i' AND relname = 'testtable_idx';
relname | size
----------------+------
testtable_idx | 1240K
(1 row)
#2. ?????????д???????????
postgres=# DELETE FROM testtable WHERE i > 20000;
DELETE 50006
#3. ????????????????????SQL????????????????????
postgres=# ANALYZE testtable;
ANALYZE
#4. ??ò????????????????????????????δ??????????????????????
postgres=# SELECT pg_relation_size('testtable_idx')/1024 || 'K' AS size;
size
------
1240K
(1 row)
#5. ?????????
postgres=# REINDEX INDEX testtable_idx;
REINDEX
#6. ??????????????????????????п??????????????????????
postgres=# SELECT pg_relation_size('testtable_idx')/1024 || 'K' AS size;
size
------
368K
(1 row)
#7. ?????????????????????????????????????????
postgres=# ANALYZE testtable;
ANALYZE
?????塢??????????????
????1. ?????????????????????????
#relpages????VACUUM??ANALYZE?????DDL??????£???CREATE INDEX????????????????8K????
postgres=# SELECT relfilenode?? relpages FROM pg_class WHERE relname = 'testtable';
relfilenode | relpages
-------------+----------
16412 | 79
(1 row)
????2. ????????????????????????????????????????
postgres=# SELECT c2.relname?? c2.relpages FROM pg_class c?? pg_class c2?? pg_index i
WHERE c.relname = 'testtable' AND c.oid = i.indrelid AND c2.oid = i.indexrelid
ORDER BY c2.relname;
relname | relpages
---------------+----------
testtable_idx | 46
(1 row)
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11