Presentation is loading. Please wait.

Presentation is loading. Please wait.

INSERTを高速化したPostgreSQL

Similar presentations


Presentation on theme: "INSERTを高速化したPostgreSQL"— Presentation transcript:

1 INSERTを高速化したPostgreSQL
Sigres INSERTを高速化したPostgreSQL

2 応答時間 各クライアントは1000件のINSERT (新マシン:RPM=7200) クライアントの同時アクセス数

3 性能比 環境:新マシン クライアントの同時アクセス数

4 何故速くなる?(1/3) ~データ挿入のメカニズム~
つまり、WALを実行しなければ高速化 UPS付メモリ:永続記憶装置 メモリ メモリ メモリ ランダムアクセス アクセス集約 ディスク ディスク ディスク ナイーブ方式 提案 WAL

5 何故速くなる?(2/3) PostgreSQLの場合は?
L(WALInsertLock) XLogInsert R(WALInsertLock) L(WALInsertLock) XLogInsert R(WALInsertLock) WALバッファ (メモリ) WALファイル (ディスク) L(WALWriteLock) XLogWrite R(WALWriteLock) まとめるとはいえ XLogWriteは write と fsync を含むので重そう

6 何故速くなる?(3/3) やったこと:XLogWriteの消去
変更前 変更後 XLogCtl->xlblocks[curridx].xrecoff); /* Advance LogwrtResult.Write to end of current buffer page */ LogwrtResult.Write = XLogCtl->xlblocks[curridx]; ispartialpage = XLByteLT(WriteRqst.Write, LogwrtResult.Write); if (!XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg)) { /* * Switch to new logfile segment. We cannot have any pending * pages here (since we dump what we have at segment end). */ Assert(npages == 0); if (openLogFile >= 0) XLogFileClose(); XLByteToPrevSeg(LogwrtResult.Write, openLogId, openLogSeg); /* create/use new log file */ use_existent = true; openLogFile = XLogFileInit(openLogId, openLogSeg, &use_existent, true); openLogOff = 0; /* update pg_control, unless someone else already did */ LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); if (ControlFile->logId < openLogId || (ControlFile->logId == openLogId && ControlFile->logSeg < openLogSeg + 1)) ControlFile->logId = openLogId; ControlFile->logSeg = openLogSeg + 1; ControlFile->time = time(NULL); UpdateControlFile(); * Signal bgwriter to start a checkpoint if it's been too long * since the last one. (We look at local copy of RedoRecPtr * which might be a little out of date, but should be close * enough for this purpose.) * * A straight computation of segment number could overflow 32 * bits. Rather than assuming we have working 64-bit * arithmetic, we compare the highest-order bits separately, * and force a checkpoint immediately when they change. if (IsUnderPostmaster) uint old_segno, new_segno; uint old_highbits, new_highbits; : #define XLogWrite(…)  do { if (…) _XLogWrite(…); } while (0) 280行⇒1行

7 危険じゃないの? UPSだけだなんて…fsyncして欲しい! やってます WALバッファ

8 メモリファイルシステムかバッテリバックアップライトキャッシュで十分では?
Pgsql-hackers ML 面白い! 8.3か8.4に マージしよう? Flash環境に 良さそう 最初の反応 Joshua Drake 最終的な反応 Tom Lane と Bruce Momijian メモリファイルシステムかバッテリバックアップライトキャッシュで十分では?

9 バッテリバックアップ ライトキャッシュ? RAM-DISK? i-ram:遅い

10 とはいえ、MFS領域のデータ退避手法は不明
メモリファイルシステム 環境:新マシン 10%~19%の性能改善に留まる とはいえ、MFS領域のデータ退避手法は不明

11 FAQと予定 FAQ 今後の予定 fsync=offとの違いは? 何でつくったの? Sigresの更なる高速化(WALInsertLock)
Sigresはログページ切り替え時にfsync発行 何でつくったの? 中間報告会後の飲み会の失言で 今後の予定 Sigresの更なる高速化(WALInsertLock) MySQL falconの高速化 MySQL MEMORYの永続化

12 まとめ UPSを前提としてINSERT/UPDATEを高速化するPostgreSQL 8.2.1対応 良かったら試してみて下さい
DL: 70 PV: 2470 天笠俊之 36 北川博之 53


Download ppt "INSERTを高速化したPostgreSQL"

Similar presentations


Ads by Google