PostgreSQL索引建立,檢視與刪除問題

2021-09-02 17:31:50 字數 527 閱讀 1332

建立方式:

create index index_sfzqfxx_czrkgmsfhm on zck.ods_gat_sfzqfxx using btree (czrkgmsfhm);

或者create index index_sfzqfxx_czrkgmsfhm on zck.ods_gat_sfzqfxx (czrkgmsfhm);

檢視索引:

select * from pg_indexes where tablename='tbname';      

或者     

select * from pg_statio_all_indexes where relname='tbname';

刪除索引:

drop index index_name;  

index_name是要刪除的索引名

注意 : 無法刪除dbms為主鍵約束和唯一約束自動建立的索引

使得新增的index 生效:

analyse zck.ods_gat_sfzqfxx;

PostgresQL建立索引如何避免寫資料鎖定

問題源自乙個帥哥在建索引發生表鎖的問題。先介紹一下postgresql的建索引語法 version 9.1 create unique index concurrently name on table using method collate collation opclass asc desc n...

PostgreSQL中的索引

索引是一種快速查詢資料的方法,它記錄了表中一列或多列與其物理位置之間的對應關係。常用的索引有b tree,hash,gist及gin等。1 b tree索引適合處理等值查詢和範圍查詢。2 hash只適合處理簡單的等值查詢。3 gist支援很多不同的索引策略。4 gin反轉索引,可以處理包含多個鍵的值...

PostgreSQL 什麼是索引?

什麼是索引?索引是提高資料庫效能的常用途徑。比起沒有索引,使用索引可以讓資料庫伺服器更快找到並獲取特定行。但是索引同時也會增加資料庫系統的日常管理負擔,因此我們應該聰明地使用索引。每種索引演算法都分別適合某些特定的查詢型別,因為他們用了不同的索引結構。pg裡的所有索引都是 從屬索引 索引在物理上與它...