Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

added limit statement to jdbc source timestamp incrementing table query #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,11 @@ protected void createPreparedStatement(Connection db) throws SQLException {
// We should capture both id = 22 (an update) and id = 23 (a new row)
builder.append(" WHERE ");
builder.append(JdbcUtils.quoteString(timestampColumn, quoteString));
builder.append(" < ? AND ((");
builder.append(" < ? AND (");
builder.append(JdbcUtils.quoteString(timestampColumn, quoteString));
builder.append(" = ? AND ");
builder.append(", ");
builder.append(JdbcUtils.quoteString(incrementingColumn, quoteString));
builder.append(" > ?");
builder.append(") OR ");
builder.append(JdbcUtils.quoteString(timestampColumn, quoteString));
builder.append(" > ?)");
builder.append(") > (?, ?)");
builder.append(" ORDER BY ");
builder.append(JdbcUtils.quoteString(timestampColumn, quoteString));
builder.append(",");
Expand All @@ -141,6 +138,7 @@ protected void createPreparedStatement(Connection db) throws SQLException {
builder.append(JdbcUtils.quoteString(timestampColumn, quoteString));
builder.append(" ASC");
}
builder.append(" LIMIT 10000");
String queryString = builder.toString();
log.debug("{} prepared SQL query: {}", this, queryString);
stmt = db.prepareStatement(queryString);
Expand All @@ -155,7 +153,6 @@ protected ResultSet executeQuery() throws SQLException {
stmt.setTimestamp(1, endTime, DateTimeUtils.UTC_CALENDAR.get());
stmt.setTimestamp(2, tsOffset, DateTimeUtils.UTC_CALENDAR.get());
stmt.setLong(3, incOffset);
stmt.setTimestamp(4, tsOffset, DateTimeUtils.UTC_CALENDAR.get());
log.debug("Executing prepared statement with start time value = {} end time = {} and incrementing value = {}",
DateTimeUtils.formatUtcTimestamp(tsOffset),
DateTimeUtils.formatUtcTimestamp(endTime),
Expand Down