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

Commit

Permalink
limit to 40K and cursor iteration rather than fetchone (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
hgulersen authored Feb 8, 2023
1 parent a5fa5a8 commit 861c2bf
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tap_redshift/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

CONFIG = {}

ROWS_PER_NETWORK_CALL = 70_000
ROWS_PER_NETWORK_CALL = 40_000


def discover_catalog(conn, db_schema):
Expand Down Expand Up @@ -373,13 +373,12 @@ def sync_table(connection, catalog_entry, state):

cursor.itersize = ROWS_PER_NETWORK_CALL
cursor.execute(select, params)
row = cursor.fetchone()
rows_saved = 0

with metrics.record_counter(None) as counter:
counter.tags['database'] = catalog_entry.database
counter.tags['table'] = catalog_entry.table
while row:
for row in cursor:
counter.increment()
rows_saved += 1
record_message = row_to_record(catalog_entry,
Expand All @@ -397,7 +396,6 @@ def sync_table(connection, catalog_entry, state):
replication_key])
if rows_saved % 1000 == 0:
yield singer.StateMessage(value=copy.deepcopy(state))
row = cursor.fetchone()

if not replication_key:
yield activate_version_message
Expand Down

0 comments on commit 861c2bf

Please sign in to comment.