- Mastering PostgreSQL 9.6
- Hans Jurgen Schonig
- 175字
- 2021-07-09 19:57:19
Adding data while indexing
Creating an index is easy. However, keep in mind that you cannot modify a table, while an index is being built. The CREATE INDEX command will lock up a table using a SHARE lock to ensure that no changes happen. While this is clearly no problem for small tables, it will cause issues on large ones on production systems. Indexing a terabyte of data or so will take some time and therefore blocking a table for too long can become an issue.
The solution to the problem is CREATE INDEX CONCURRENTLY command. Building the index will take a lot longer (usually at least twice as long) but you can use the table normally during index creation.
Here is how it works:
test=# CREATE INDEX CONCURRENTLY idx_name2 ON t_test (name);
CREATE INDEX
Note that PostgreSQL does not guarantee success if you are using the CREATE INDEX CONCURRENTLY command. An index can end up being marked as invalid if the operations going on on your system somehow conflict with index creation.
- Verilog HDL數字系統設計入門與應用實例
- Photoshop CS3特效處理融會貫通
- 機器人編程實戰
- 21天學通Java Web開發
- Excel 2007技巧大全
- 貫通Java Web開發三劍客
- Learn QGIS
- 數據要素:全球經濟社會發展的新動力
- Learning Cassandra for Administrators
- 樂高創意機器人教程(中級 上冊 10~16歲) (青少年iCAN+創新創意實踐指導叢書)
- 從祖先到算法:加速進化的人類文化
- Cisco UCS Cookbook
- Mastering Android Game Development with Unity
- 時序大數據平臺TDengine核心原理與實戰
- 亮劍.NET:圖解ASP.NET網站開發實戰