-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Source Postgres : Emit estimate trace messages for non-CDC mode #20783
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
aa40c0c
Emit estimate trace messages
akashkulk 0b72bde
Merge branch 'master' into message_bar
akashkulk 98e4c16
Update PostgresQueryUtils.java
akashkulk bac0933
Remaining merge conflicts
akashkulk 838bb69
Code cleanip
akashkulk e6fce71
Address comments
akashkulk c1555d4
Formatting
akashkulk 7303650
Merge branch 'master' into message_bar
akashkulk c686aee
Merge branch 'master' into message_bar
akashkulk 9e443d2
Cleanup
akashkulk 9774447
Merge branch 'master' into message_bar
akashkulk 49b1447
Addressing comments
akashkulk d47af6a
Merge branch 'master' into message_bar
akashkulk 4448d81
Bump version + documentation
akashkulk b63079e
Update strict-encrypt Dockerfile
akashkulk a4f3d24
Unpublish
akashkulk c0c6061
Merge branch 'master' into message_bar
akashkulk d0b6352
Merge branch 'master' into message_bar
akashkulk 25e8061
Merge conflicts
akashkulk 85808ea
Merge branch 'master' into message_bar
akashkulk 9e427c0
Merge branch 'master' into message_bar
akashkulk 2f08fda
Update Dockerfile
akashkulk c2b4557
Merge branch 'master' into message_bar
akashkulk 40c2eb8
auto-bump connector version
octavia-squidington-iii 8dad719
Merge branch 'master' into message_bar
akashkulk 48f1818
Merge branch 'master' into message_bar
akashkulk bc311af
Merge branch 'master' into message_bar
akashkulk 9be7285
Merge branch 'master' into message_bar
akashkulk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ce-postgres/src/main/java/io/airbyte/integrations/source/postgres/PostgresQueryUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.source.postgres; | ||
|
||
/** | ||
* Utility class to define constants related to querying postgres | ||
*/ | ||
public class PostgresQueryUtils { | ||
|
||
public static final String NULL_CURSOR_VALUE_WITH_SCHEMA_QUERY = | ||
""" | ||
SELECT | ||
(EXISTS (SELECT FROM information_schema.columns WHERE table_schema = '%s' AND table_name = '%s' AND is_nullable = 'YES' AND column_name = '%s')) | ||
AND | ||
(EXISTS (SELECT from \"%s\".\"%s\" where \"%s\" IS NULL LIMIT 1)) AS %s | ||
"""; | ||
public static final String NULL_CURSOR_VALUE_NO_SCHEMA_QUERY = | ||
""" | ||
SELECT | ||
(EXISTS (SELECT FROM information_schema.columns WHERE table_name = '%s' AND is_nullable = 'YES' AND column_name = '%s')) | ||
AND | ||
(EXISTS (SELECT from \"%s\" where \"%s\" IS NULL LIMIT 1)) AS %s | ||
"""; | ||
|
||
public static final String TABLE_ESTIMATE_QUERY = | ||
""" | ||
SELECT (SELECT COUNT(*) FROM %s) AS %s, | ||
pg_relation_size('%s') AS %s; | ||
"""; | ||
|
||
public static final String ROW_COUNT_RESULT_COL = "rowcount"; | ||
|
||
public static final String TOTAL_BYTES_RESULT_COL = "totalbytes"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description says the intention is to only estimate table sizes using
pg_relation_size
, but won't this query end up doing a full count also? I believe this is what's causing my sync to hang for minutes (and maybe more) as attempting a count on my 186M row table takes quite a while.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the number of rows is needed, I'd recommend using an estimate via
SELECT reltuples AS estimate FROM pg_class WHERE relname = 'table_name'
. [1]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha, you know about this as part of #21499.