- 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.
- PPT,要你好看
- GNU-Linux Rapid Embedded Programming
- Introduction to DevOps with Kubernetes
- 輕松學(xué)Java
- Learning Apache Cassandra(Second Edition)
- Python:Data Analytics and Visualization
- 電腦上網(wǎng)輕松入門
- 空間機(jī)械臂建模、規(guī)劃與控制
- 生成對(duì)抗網(wǎng)絡(luò)項(xiàng)目實(shí)戰(zhàn)
- WPF專業(yè)編程指南
- 網(wǎng)絡(luò)信息安全項(xiàng)目教程
- iLike就業(yè)SQL多功能教材
- Machine Learning for Healthcare Analytics Projects
- 時(shí)序大數(shù)據(jù)平臺(tái)TDengine核心原理與實(shí)戰(zhàn)
- DevOps:Puppet,Docker,and Kubernetes