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

Small performance improvements.

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