提交 4f3a6422 authored 作者: christian.peter.io's avatar christian.peter.io

New experimental feature "SHUTDOWN DEFRAG". This option optimizes the page layout so

    that a full table scan is faster.
上级 74827696
...@@ -524,40 +524,44 @@ public class PageStore implements CacheWriter { ...@@ -524,40 +524,44 @@ public class PageStore implements CacheWriter {
ri.close(); ri.close();
} }
recordPageReads = false; recordPageReads = false;
int currentSeqPosInDb = MIN_PAGE_COUNT; int free = getFirstFree(); // We swap, so this page is fix
for (int i = 0; i < recordedPagesList.size(); i++) { if (free == -1) {
writeBack(); DbException.throwInternalError("no free page for defrag");
cache.clear(); } else {
int free = getFirstFree(); int currentSeqPosInDb = MIN_PAGE_COUNT;
int a = currentSeqPosInDb; for (int i = 0; i < recordedPagesList.size(); i++) {
int b = recordedPagesList.get(i); writeBack();
cache.clear();
if (a == b) { int a = currentSeqPosInDb;
continue; int b = recordedPagesList.get(i);
}
if (a == b) {
boolean swapped = swap(a, b, free); continue;
if (!swapped) { }
DbException.throwInternalError("swapping not possible: " + a + " with " + b + " via " + free);
}
int index = recordedPagesList.indexOf(a);
if (index != -1) {
recordedPagesList.set(index, b);
}
recordedPagesList.set(i, a);
// Find next PageDataLeaf boolean swapped = swap(a, b, free);
while (true) { if (!swapped) {
currentSeqPosInDb++; DbException.throwInternalError("swapping not possible: " + a + " with " + b + " via " + free);
if (currentSeqPosInDb >= pageCount) {
currentSeqPosInDb = -1;
} }
Page currentPage = getPage(currentSeqPosInDb); int index = recordedPagesList.indexOf(a);
if (currentPage == null) { if (index != -1) {
continue; recordedPagesList.set(index, b);
} }
if (currentPage instanceof PageDataLeaf) { recordedPagesList.set(i, a);
break;
while (true) {
currentSeqPosInDb++;
if (currentSeqPosInDb >= pageCount) {
currentSeqPosInDb = -1;
break;
}
Page currentPage = getPage(currentSeqPosInDb);
if (currentPage == null) {
continue;
}
if (currentPage instanceof PageDataLeaf) {
break;
}
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论