大資料量使用總結

2021-07-10 03:35:28 字數 1997 閱讀 4686

1.利用partition

partition by range(field)

( partition p1 values less than ('v1'), --由欄位型別決定引號

partition p2 values less than ('v2'),

partition pmax values less than (maxvalue) -- 關鍵字

);select

count(*) from table_name partition(p2);

--再次分割槽

alter

table table_name split partition pmax at('v3') into (partition p2,partition pmax);

2.索引,日誌

alter

table table_name nologging;

--無日誌模式,不能回滾操作

alter

table table_name add

constraint pk_table_name primary

key(field1)

using index;

-- 新增約束

create index idx_table_name on table_name(field2);

--新增索引

select

'alter index '||index_name||' rebuild;'

from user_indexes where status='unusable' [ and tablespace_name <> 'v1'];

-- 查詢失效索引

alter index index_name rebuild [ tablespace v1];

--重建索引 [移到指定表空間]

select

'alter table '||table_name || ' mov tablespace v1;'

from user_tables t

where tablespace_name <> v1

andexists (

select

null fromuser_tab_cols

where table_name = t.table_name

and data_type not

in ('long','blob','clob')

);-- 查詢表空間不是v1,並且將表移到v1表空間

特點:那麼系統加的是rowexclusive鎖,也就是正常insert所加的行級鎖,

系統加的是exclusive鎖,相當於表級鎖,加表級鎖意味著在本會話沒有commit的時候其他任何會話都不能再進行insert,update,delete操作。

檢查資料庫歸檔模式(noarchivelog、archivelog)

select log_mode from v$database;

select name,value,class from v$sysstat 

where name='redo size';

-- 檢視當前redo日誌大小:

set autotrace traceonly statistics ;統計當前語句生成的redo,

4.快速更新(hint方法)

select /*+ parallel */ count(*) from t;

--update 同select

update 

(select /*+ by_pass */ t.field from t )

set t.field = 'v1';

--select 同parallel

大資料量演算法

給40億個不重複的unsigned int的整數,沒排過序的,然後再給乙個數,如何快速判斷這個數是否在那40億個數當中 位圖思想解法 include stdio.h include stdlib.h include memory.h define max num 4294967295 int mai...

大資料量處理

看看這個,異曲同工,永遠不超時 該程式是針對非常龐大的資料庫開發的,沒有用迴圈 用途 對過萬條資料的資料庫字段內容批量替換 資料庫連線 dim beeyee dbname,connstr,conn,intsn1 dim content,num,intsn,intidno,strcodea,strco...

航測大資料量處理 大資料量處理及優化措施

1 首先考慮垂直拆分庫,不同的表拆分到不同的庫中,例如使用者庫 產品庫 支付庫 2 然後考慮水平拆分庫,將乙個表的資料放到多張表中,例如按照使用者 時間 訂單號 3 插入資料的時候不建立索引 4 待資料已經插入完成後,建立索引 5 正確的指定索引字段 6 使用批量插入資料庫的方式代替單條資料的插入 ...