抓出where使用且未建索引且指定選擇性的列

2021-07-09 03:03:37 字數 2054 閱讀 9193

/*

1. 抓出列選擇性》=20 的列

2. 這個列沒有建立索引

3. 這個列出現在where條件中

*/這裡面的owner值自己改改。(師從落落,請勿噴我

with u as

(select 'normphone' owner from dual)

select a.owner,

a.table_name,

a.column_name,

a.selectivity,

b.owner,

b.table_name,

b.column_name,

c.owner,

c.table_name,

c.column_name

from (select a.owner,

a.table_name,

a.column_name,

b.num_rows,

a.num_distinct cardinality,

decode(b.num_rows,

null,

0,0,

0,round(a.num_distinct / b.num_rows * 100, 2)) selectivity,

a.histogram,

a.num_buckets

from dba_tab_col_statistics a, dba_tables b, u

where a.owner = b.owner

and a.owner = u.owner

and a.table_name = b.table_name) a

left join (select r.name owner,

o.name table_name,

c.name column_name,

equality_preds, ---等值過濾

equijoin_preds, ---等值join過濾 比如where a.id=b.id

nonequijoin_preds, ----不等join過濾

range_preds, ----範圍過濾 &get; &get;= < <= between and

like_preds, ----like過濾

null_preds, ----null 過濾

timestamp

from sys.col_usage$ u, sys.obj$ o, sys.col$ c, sys.user$ r, u

where o.obj# = u.obj#

and c.obj# = u.obj#

and c.col# = u.intcol#

and o.owner# = r.user#

and r.name = u.owner) b

on a.owner = b.owner

and a.table_name = b.table_name

and a.column_name = b.column_name

left join (select t.index_owner owner, t.table_name, t.column_name

from all_ind_columns t, u

where t.index_owner = u.owner) c

on a.owner = c.owner

and a.table_name = c.table_name

and a.column_name = c.column_name

where a.selectivity >= 20

and (b.owner is not null and b.table_name is not null and

b.column_name is not null)

and(c.owner is null and c.table_name is null and c.column_name is null)

完成。

ABAP 動態where 使用

report ztest001 xch.tables makt.data where tab 80 occurs 10 with header line.data wa itab like makt occurs 10with header line.parameters s trx like ma...

My SQL 使用WHERE過濾資料

where關鍵字相當於excel的篩選,不同的是where只能實現完全匹配,不能實現部分匹配,相同的是,where不區分大小寫,即如果判定where prod id fb 同樣可以篩選出fb的行。在同時使用order by和where時,應該將order by位於where之後。在這裡我們假設有一張...

最近最久未使用

最近最久未使用 lru 的頁面置換演算法是根據頁面調入記憶體後的使用情況做出決策的。由於無法 各頁面將來的使用情況,只能利用 最近的過去 作為 最近的將來 的近似,因此,lru置換演算法是選擇最近最久未使用的頁面予以淘汰。該演算法賦予每個頁面乙個訪問字段,用來記錄乙個頁面自上次被訪問以來所經歷的時間...