HINT無效的幾個場景

2021-09-25 14:33:35 字數 1580 閱讀 7249

碰巧看見了dba-oracle上的乙個問題,算是基礎性問題,

問題就是某些檢索中,即使指定了index hint,可能無效。

回答是,如果這個index hint的語法格式錯誤,就會只將他看作乙個注釋,不會應用這個hint。

inindex hint的標準用法是/*+ index(table_name, index_name) */,其中的","可以省略,換成空格。

舉出了幾個正確的使用,測試表和資料,

sql> select * from customer;

id a

1 a

2 b3 c

4 d5 e

一開始,只是為這個id建立了索引,

sql> create index pk_customer on customer(id);

index created.

此時執行index hint的sql,

sql> select /*+ index(customer, pk_customer) */ * from customer;
發現這個hint未生效,語法格式沒問題,這是什麼錯?

這個隱藏的問題,其實就是索引的內容,因為索引不包含空值,換句話說,id列可能為空,因此索引中就可能為空,cbo認為hint會導致錯誤結果,那麼這個hint就會被忽略,所以選擇了全表掃瞄。

解決方案就是設定這個id非空約束,為了測試,直接將其設定為主鍵,這藏著另乙個知識點,之前在摩天輪中看見個問題,如何建立主鍵,這兩種操作,都是正確的,區別就是第一種可以設定主鍵約束的名稱,第二種會由系統自動建立乙個名稱,例如sys_c000000,從標準的角度看,建議第一種,

sql> alter table customer add constraint pk_customer primary key(id);

table altered.

sql> alter table customer add primary key (id);

table altered.

回到主題上,此時執行index hint的sql,

sql> select /*+ index(customer, pk_customer) */ * from customer;
此時使用了索引全掃瞄,說明這個hint生效了,

如果檢索的表設定了別名,index hint就需要使用別名,不能是這個表名,

使用表名,

sql> select /*+ index(customer, pk_customer) */ * from customer c;

index hint無效,

使用別名,

sql> select /*+ index(c, pk_customer) */ * from customer c;

index hint生效,

如果多個hint衝突了,hint無效,

sql> select /*+ full(customer) index(customer pk_customer) */ * from customer;

顯示未用索引。

DOM幾個場景的優化場景?

問題 在input的onchange事件中進行實時請求,當輸入框輸入發生改變時就會傳送一次請求。比如輸入react 解決方式 新增防抖功能,設定乙個合理的時間間隔,避免時間在時間間隔內頻繁觸發,同時又能保證輸入後可以看到結果 1 每次value改變,就會發出一次請求 const handlechan...

設定EditText的hint字型大小

背景 edittext能設定hint的顏色,但是卻不能設定hint的字型大小,導致hint的字型和text的字型是一樣的。但有時hint較長,需要把字型縮小。解決方案 設定edittext的hint字型大小 param edittext edittext控制項 param hinttext hint...

對hint的調優

實際工作中經常遇到開發人員加hint為提高資料的批處理的速度,但為了提高處理速度經常遇到並行的hint隨意使用,並行不是萬能的,不合理的使用只能阻礙執行速度,使用如下sql說明並行問題 select leading t1 use hash t lgin parallel t1,8 t1.rpo no...