提交 f9c41310 authored 作者: Thomas Mueller's avatar Thomas Mueller

Small performance improvements.

上级 f30b2e82
......@@ -345,7 +345,7 @@ public abstract class Prepared {
* @param rowNumber the row number
*/
protected void setCurrentRowNumber(int rowNumber) throws SQLException {
if ((rowScanCount++ & 127) == 0) {
if ((++rowScanCount & 127) == 0) {
checkCanceled();
}
this.currentRowNumber = rowNumber;
......
......@@ -64,7 +64,7 @@ public class Delete extends Prepared {
}
int rowScanCount = 0;
for (rows.reset(); rows.hasNext();) {
if ((rowScanCount++ & 127) == 0) {
if ((++rowScanCount & 127) == 0) {
checkCanceled();
}
Row row = rows.next();
......
......@@ -227,11 +227,15 @@ public class Comparison extends Condition {
}
return ValueBoolean.get(result);
}
l = l.convertTo(dataType);
Value r = right.getValue(session).convertTo(dataType);
if (l == ValueNull.INSTANCE || r == ValueNull.INSTANCE) {
if (l == ValueNull.INSTANCE) {
return ValueNull.INSTANCE;
}
Value r = right.getValue(session);
if (r == ValueNull.INSTANCE) {
return ValueNull.INSTANCE;
}
l = l.convertTo(dataType);
r = r.convertTo(dataType);
boolean result = compareNotNull(database, l, r, compareType);
return ValueBoolean.get(result);
}
......
......@@ -382,7 +382,7 @@ public abstract class Table extends SchemaObjectBase {
// remove the old rows
int rowScanCount = 0;
for (rows.reset(); rows.hasNext();) {
if ((rowScanCount++ & 127) == 0) {
if ((++rowScanCount & 127) == 0) {
prepared.checkCanceled();
}
Row o = rows.next();
......@@ -392,7 +392,7 @@ public abstract class Table extends SchemaObjectBase {
}
// add the new rows
for (rows.reset(); rows.hasNext();) {
if ((rowScanCount++ & 127) == 0) {
if ((++rowScanCount & 127) == 0) {
prepared.checkCanceled();
}
rows.next();
......
......@@ -68,6 +68,13 @@ public class TableData extends Table implements RecordReader {
private boolean containsLargeObject;
private PageDataIndex mainIndex;
/**
* True if one thread ever was waiting to lock this table. This is to avoid
* calling notifyAll if no session was ever waiting to lock this table. If
* set, the flag stays. In theory, it could be reset, however not sure when.
*/
private boolean waitForLock;
public TableData(CreateTableData data) throws SQLException {
super(data.schema, data.id, data.tableName, data.persistIndexes, data.persistData);
Column[] cols = new Column[data.columns.size()];
......@@ -507,6 +514,7 @@ public class TableData extends Table implements RecordReader {
if (sleep == 0) {
sleep = 1;
}
waitForLock = true;
database.wait(sleep);
} catch (InterruptedException e) {
// ignore
......@@ -643,7 +651,7 @@ public class TableData extends Table implements RecordReader {
// TODO lock: maybe we need we fifo-queue to make sure nobody
// starves. check what other databases do
synchronized (database) {
if (database.getSessionCount() > 1) {
if (database.getSessionCount() > 1 && waitForLock) {
database.notifyAll();
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论