setTmpFetchSize(25100)

This commit is contained in:
Wisser
2023-04-17 08:53:29 +02:00
parent 9fdc65b229
commit d0dea57c86
3 changed files with 39 additions and 25 deletions
@@ -25,7 +25,7 @@ public class JailerVersion {
/**
* The Jailer version.
*/
public static final String VERSION = "14.5.0.2";
public static final String VERSION = "14.6";
/**
* The Jailer working tables version.
@@ -45,7 +45,3 @@ public class JailerVersion {
}
}
// TODO
// TODO engine release pending (14.6). See DBMS#getLimitedFetchSize()
@@ -1381,17 +1381,33 @@ public class DBMS {
return true;
}
private static final ThreadLocal<Integer> tmpFetchSize = new ThreadLocal<>();
public static void setTmpFetchSize(Integer tmpFetchSize) {
DBMS.tmpFetchSize.set(tmpFetchSize);
}
public int getLimitedFetchSize(long limit) {
final int DEFAULT_FETCH_SIZE = 20010;
Integer fSize = getFetchSize();
if (fSize != null) {
if (limit > 0 && limit <= DEFAULT_FETCH_SIZE) {
return (int) (limit + 1 + 1);
} else {
if (fSize < 0) {
return fSize;
}
}
final int DEFAULT_FETCH_SIZE = 5010;
if (fSize == null) {
fSize = DEFAULT_FETCH_SIZE;
}
Integer dfs = tmpFetchSize.get();
if (dfs == null) {
dfs = fSize;
}
if (limit > 0 && limit <= dfs) {
return (int) (limit + 1 + 1);
} else {
return DEFAULT_FETCH_SIZE;
return dfs;
}
}
@@ -87,6 +87,7 @@ import javax.swing.text.BadLocationException;
import org.fife.ui.rtextarea.SmartHighlightPainter;
import net.sf.jailer.ExecutionContext;
import net.sf.jailer.configuration.DBMS;
import net.sf.jailer.database.InlineViewStyle;
import net.sf.jailer.database.Session;
import net.sf.jailer.database.Session.AbstractResultSetReader;
@@ -2293,19 +2294,24 @@ public abstract class WhereConditionEditorPanel extends javax.swing.JPanel {
}
}
};
if (orderBy) {
Map<String, Integer> prev = new HashMap<String, Integer>(result);
try {
session.executeQuery(sqlQuery + " order by " + (inSQLConsole()? "val" : columnName), reader, null, cancellationContext, MAX_NUM_DISTINCTEXISTINGVALUES + 2);
} catch (SQLException e) {
result.clear();
result.putAll(prev);
// try without ordering
DBMS.setTmpFetchSize(25100);
try {
if (orderBy) {
Map<String, Integer> prev = new HashMap<String, Integer>(result);
try {
session.executeQuery(sqlQuery + " order by " + (inSQLConsole()? "val" : columnName), reader, null, cancellationContext, MAX_NUM_DISTINCTEXISTINGVALUES + 2);
} catch (SQLException e) {
result.clear();
result.putAll(prev);
// try without ordering
session.executeQuery(sqlQuery, reader, null, cancellationContext, MAX_NUM_DISTINCTEXISTINGVALUES + 2);
sortValues(result, columnIndex);
}
} else {
session.executeQuery(sqlQuery, reader, null, cancellationContext, MAX_NUM_DISTINCTEXISTINGVALUES + 2);
sortValues(result, columnIndex);
}
} else {
session.executeQuery(sqlQuery, reader, null, cancellationContext, MAX_NUM_DISTINCTEXISTINGVALUES + 2);
} finally {
DBMS.setTmpFetchSize(null);
}
}
@@ -2633,7 +2639,3 @@ public abstract class WhereConditionEditorPanel extends javax.swing.JPanel {
}
// TODO
// TODO Abteilung1.ObjektId wird auf 62 nicht gecached?!