--以 t_credit_trans_tag 表為例
--查詢索引
select * from pg_indexes where tablename='t_credit_trans_tag';
--建立索引
create index time_index on pay_data.t_credit_trans_tag using btree (create_time);
create unique index t_credit_trans_tag_pkey on pay_data.t_credit_trans_tag using btree (id);
--刪除索引
drop index time_index;
注意:
雖然索引的目的在於提高資料庫的效能,但這裡有幾個情況需要避免使用索引。
使用索引時,需要考慮下列準則:
1、索引不應該使用在較小的表上。
2、索引不應該使用在有頻繁的大批量的更新或插入操作的表上。
3、索引不應該使用在含有大量的null值的列上。
4、索引不應該使用在頻繁操作的列上。
Mongo or查詢優化與建立索引
db.getcollection user find 使用者編號,手機號,裝置號三個條件進行or查詢,可以有多種建立索引的方式,比如 1.建立userno 1 phone 1 imei 1的聯合索引 2.建立單獨的userno,imei索引等 但是經過explain 檢視後發現,建立的聯合索引不起作...
Oracle建立索引 查詢索引
1 建立索引 create index 索引名 on 表名 列名 2 刪除索引 drop index 索引名 3 建立組合索引 create index 索引名 on 表名 列名1,列名2 檢視目標表中已新增的索引 在資料庫中查詢表名 select fromuser tableswheretable...
Oracle建立索引 查詢索引
第一種命令建立 1 建立索引 create index 索引名 on 表名 列名 2 刪除索引 drop index 索引名 3 建立組合索引 create index 索引名 on 表名 列名1,列名2 4.檢視目標表中已新增的索引 在資料庫中查詢表名 select from user table...