Skip to content

Commit

Permalink
Updated query to use TOP instead of LIMIT
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenaiden authored and rodireich committed Jan 12, 2024
1 parent 13e6503 commit 7b4dfea
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private PreparedStatement getPkPreparedStatement(final Connection connection) {
if (isCompositeKeyLoad) {
sql = "SELECT %s FROM %s ORDER BY %s".formatted(wrappedColumnNames, fullTableName, quotedCursorField);
} else {
sql = "SELECT %s FROM %s ORDER BY %s LIMIT %s".formatted(wrappedColumnNames, fullTableName, quotedCursorField, chunkSize);
sql = "SELECT TOP %s %s FROM %s ORDER BY %s".formatted(chunkSize, wrappedColumnNames, fullTableName, quotedCursorField);
}
final PreparedStatement preparedStatement = connection.prepareStatement(sql);
LOGGER.info("Executing query for table {}: {}", tableName, preparedStatement);
Expand All @@ -139,8 +139,8 @@ private PreparedStatement getPkPreparedStatement(final Connection connection) {
// can just issue a query
// without any chunking.
if (ocInfo.ocMaxValue() != null) {
sql = "SELECT %s FROM %s WHERE %s > ? AND %s <= ? ORDER BY %s LIMIT %s".formatted(wrappedColumnNames, fullTableName,
quotedCursorField, quotedCursorField, quotedCursorField, chunkSize);
sql = "SELECT TOP %s %s FROM %s WHERE %s > ? AND %s <= ? ORDER BY %s".formatted(chunkSize, wrappedColumnNames, fullTableName,
quotedCursorField, quotedCursorField, quotedCursorField);
} else {
sql = "SELECT %s FROM %s WHERE %s > ? ORDER BY %s".formatted(wrappedColumnNames, fullTableName,
quotedCursorField, quotedCursorField);
Expand Down

0 comments on commit 7b4dfea

Please sign in to comment.