提交 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,11 +524,14 @@ public class PageStore implements CacheWriter { ...@@ -524,11 +524,14 @@ public class PageStore implements CacheWriter {
ri.close(); ri.close();
} }
recordPageReads = false; recordPageReads = false;
int free = getFirstFree(); // We swap, so this page is fix
if (free == -1) {
DbException.throwInternalError("no free page for defrag");
} else {
int currentSeqPosInDb = MIN_PAGE_COUNT; int currentSeqPosInDb = MIN_PAGE_COUNT;
for (int i = 0; i < recordedPagesList.size(); i++) { for (int i = 0; i < recordedPagesList.size(); i++) {
writeBack(); writeBack();
cache.clear(); cache.clear();
int free = getFirstFree();
int a = currentSeqPosInDb; int a = currentSeqPosInDb;
int b = recordedPagesList.get(i); int b = recordedPagesList.get(i);
...@@ -546,11 +549,11 @@ public class PageStore implements CacheWriter { ...@@ -546,11 +549,11 @@ public class PageStore implements CacheWriter {
} }
recordedPagesList.set(i, a); recordedPagesList.set(i, a);
// Find next PageDataLeaf
while (true) { while (true) {
currentSeqPosInDb++; currentSeqPosInDb++;
if (currentSeqPosInDb >= pageCount) { if (currentSeqPosInDb >= pageCount) {
currentSeqPosInDb = -1; currentSeqPosInDb = -1;
break;
} }
Page currentPage = getPage(currentSeqPosInDb); Page currentPage = getPage(currentSeqPosInDb);
if (currentPage == null) { if (currentPage == null) {
...@@ -561,6 +564,7 @@ public class PageStore implements CacheWriter { ...@@ -561,6 +564,7 @@ public class PageStore implements CacheWriter {
} }
} }
} }
}
recordedPagesList = null; recordedPagesList = null;
recordedPagesSet = null; recordedPagesSet = null;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论