- 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.
- 三菱FX3U/5U PLC從入門到精通
- 空間機(jī)器人遙操作系統(tǒng)及控制
- Visual C# 2008開(kāi)發(fā)技術(shù)實(shí)例詳解
- 群體智能與數(shù)據(jù)挖掘
- 四向穿梭式自動(dòng)化密集倉(cāng)儲(chǔ)系統(tǒng)的設(shè)計(jì)與控制
- Android游戲開(kāi)發(fā)案例與關(guān)鍵技術(shù)
- PostgreSQL 10 Administration Cookbook
- INSTANT Heat Maps in R:How-to
- INSTANT Adobe Story Starter
- 伺服與運(yùn)動(dòng)控制系統(tǒng)設(shè)計(jì)
- 開(kāi)放自動(dòng)化系統(tǒng)應(yīng)用與實(shí)戰(zhàn):基于標(biāo)準(zhǔn)建模語(yǔ)言IEC 61499
- ARM體系結(jié)構(gòu)與編程
- 信息系統(tǒng)安全保障評(píng)估
- 牛津通識(shí)讀本:大數(shù)據(jù)(中文版)
- Learning OpenShift