使用緩衝區載入資料
下列範例 MaxL 作業示範如何使用暫時載入緩衝區來簡化將資料載入至 Essbase 彙總儲存 (ASO) 資料庫。
如果您使用多個匯入資料 (聚總儲存) 敘述句來載入資料值以聚總儲存資料庫,您可以先將值載入暫時資料載入緩衝區,並在所有資料來源都已讀取之後,以最終寫入儲存體,大幅提升效能。
記憶體中存在資料載入緩衝區時,您無法建立聚總或合併磁碟片段,因為這些作業會耗用大量資源。不過,您可以將資料載入其他資料載入緩衝區,並對資料庫執行查詢與其他作業。在將完整資料集確認至資料庫並建立聚總之前,可能會短暫等待查詢。
在緩衝區內容確認至資料庫或重新啟動應用程式之前,資料載入緩衝區會存在於記憶體中。即使確認作業失敗,緩衝區也會損毀,但資料也不會載入資料庫。
單一聚總儲存資料庫上可以有多個資料載入緩衝區。為了節省時間,您可以使用個別的 MaxL Shell 階段作業,同時將資料載入多個資料載入緩衝區。儘管資料庫上只有一個資料載入確認作業可以隨時作用,但您可以在相同的確認作業中確認多個資料載入緩衝區,這比個別確認緩衝區的速度快。
您可以查詢資料庫,取得存在於聚總儲存資料庫上的資料載入緩衝區清單與描述。請參閱清單聚總儲存資料載入緩衝區。
範例:
範例:將多個資料來源載入單一資料載入緩衝區
假設有三個需要匯入的資料檔。使用聚總儲存資料庫時,使用單一匯入作業載入所有資料檔時,資料載入最有效率。因此,載入緩衝區在載入多個資料檔時非常有用。
-
使用更改資料庫 (聚總儲存) 建立載入緩衝區。
alter database ASOsamp.Basic initialize load_buffer with buffer_id 1; -
使用 Import Data (Aggregate Storage) 敘述句將資料載入緩衝區。
import database ASOsamp.Basic data from server data_file 'file_1' to load_buffer with buffer_id 1 on error abort; import database ASOsamp.Basic data from server data_file 'file_2' to load_buffer with buffer_id 1 on error abort; import database ASOsamp.Basic data from server data_file 'file_3' to load_buffer with buffer_id 1 on error abort; -
將資料從緩衝區移到資料庫。
import database ASOsamp.Basic data from load_buffer with buffer_id 1;資料載入緩衝區被隱含毀棄。
-
假設在步驟 2 中,將 'file_2' 載入載入緩衝區之後,您決定不載入資料。因為資料位於緩衝區中,但尚未在資料庫中,所以只要使用更改資料庫 (聚總儲存) 即可銷毀緩衝區,而不會將資料移至資料庫。
alter database ASOsamp.Basic destroy load_buffer with buffer_id 1;
範例:平行執行多個資料載入
-
在一個 MaxL Shell 階段作業中,將資料載入 ID 為 1 的緩衝區:
alter database ASOsamp.Basic initialize load_buffer with buffer_id 1 resource_usage 0.5;import database ASOsamp.Basic data from data_file "dataload1.txt" to load_buffer with buffer_id 1 on error abort; -
在另一個 MaxL Shell 階段作業中,同時將資料載入 ID 為 2 的緩衝區:
alter database ASOsamp.Basic initialize load_buffer with buffer_id 2 resource_usage 0.5;import database ASOsamp.Basic data from data_file "dataload2.txt" to load_buffer with buffer_id 2 on error abort; -
當資料完全載入資料載入緩衝區時,請使用一個 MaxL 敘述句,透過使用以逗號區隔的緩衝區 ID 清單,將兩個緩衝區的內容確認至資料庫:
import database ASOsamp.Basic data from load_buffer with buffer_id 1, 2;