Skip to content
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

Postgres support for partitioned tables #3339

Merged
merged 16 commits into from
Mar 10, 2025

Conversation

alishakawaguchi
Copy link
Contributor

@alishakawaguchi alishakawaguchi commented Mar 7, 2025

Fixed neosync type bug when updating table
Fixed postgres get extensions query returning all schema specific extensions

Copy link

vercel bot commented Mar 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
neosync-docs ⬜️ Ignored (Inspect) Visit Preview Mar 10, 2025 8:52pm

@alishakawaguchi alishakawaguchi self-assigned this Mar 7, 2025
@alishakawaguchi alishakawaguchi added enhancement New feature or request bug Something isn't working labels Mar 7, 2025
Copy link

codecov bot commented Mar 7, 2025

Codecov Report

Attention: Patch coverage is 0% with 69 lines in your changes missing coverage. Please review.

Project coverage is 24.62%. Comparing base (dd7dd4e) to head (1d52b9f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ackend/pkg/sqlmanager/postgres/postgres-manager.go 0.00% 55 Missing ⚠️
internal/benthos/benthos-builder/builders/sql.go 0.00% 13 Missing ⚠️
...ernal/testutil/testcontainers/postgres/postgres.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3339      +/-   ##
==========================================
- Coverage   24.65%   24.62%   -0.03%     
==========================================
  Files         395      395              
  Lines       45872    45919      +47     
==========================================
- Hits        11310    11308       -2     
- Misses      33441    33489      +48     
- Partials     1121     1122       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

github-actions bot commented Mar 7, 2025

Benchstat Geomean Results

0.26% sec/op, -0.02% B/op, 0.00% allocs/op

Benchstat results
                                   │ main-benchmark.txt │        branch-benchmark.txt        │
                                   │       sec/op       │    sec/op     vs base              │
CleanPostgresType-4                         42.63n ± 4%   42.41n ± 89%       ~ (p=0.223 n=6)
Runner_Single-4                             7.713µ ± 5%   7.761µ ±  2%       ~ (p=0.818 n=6)
GenerateBool-4                              11.45n ± 1%   11.39n ±  2%       ~ (p=0.258 n=6)
GenerateBusinessName-4                      285.4n ± 0%   297.9n ± 10%  +4.38% (p=0.002 n=6)
GenerateCardNumber-4                        28.41n ± 1%   28.37n ±  1%       ~ (p=0.374 n=6)
GenerateCategorical-4                       104.1n ± 2%   102.9n ±  1%  -1.20% (p=0.002 n=6)
GenerateCity-4                              173.7n ± 0%   172.7n ±  1%  -0.58% (p=0.050 n=6)
GenerateCountry-4                           105.2n ± 1%   107.4n ±  1%  +2.09% (p=0.002 n=6)
GenerateEmail-4                             1.346µ ± 0%   1.353µ ±  0%  +0.52% (p=0.002 n=6)
GenerateFirstName-4                         203.9n ± 0%   201.9n ±  2%       ~ (p=0.065 n=6)
GenerateFloat64-4                           28.73n ± 1%   28.66n ±  3%       ~ (p=0.589 n=6)
GenerateFullAddress-4                       1.429µ ± 3%   1.436µ ±  0%       ~ (p=0.327 n=6)
GenerateFullName-4                          1.222µ ± 1%   1.271µ ± 13%  +4.05% (p=0.004 n=6)
GenerateGender-4                            41.42n ± 0%   41.41n ±  0%       ~ (p=0.253 n=6)
GenerateInt64-4                             28.41n ± 2%   28.26n ±  1%       ~ (p=0.729 n=6)
GenerateInt64PhoneNumber-4                  51.46n ± 2%   51.48n ±  0%       ~ (p=0.937 n=6)
GenerateInternationalPhoneNumber-4          175.8n ± 1%   174.9n ±  1%  -0.51% (p=0.026 n=6)
GenerateIpAddress-4                         569.3n ± 0%   522.4n ±  1%  -8.24% (p=0.002 n=6)
GenerateLastName-4                          187.4n ± 1%   189.3n ±  0%  +1.01% (p=0.006 n=6)
GenerateRandomString-4                      985.6n ± 1%   982.8n ±  1%       ~ (p=0.310 n=6)
GenerateSHA256Hash-4                        1.016µ ± 0%   1.021µ ±  1%  +0.44% (p=0.006 n=6)
GenerateSSN-4                               305.8n ± 1%   303.6n ±  1%  -0.74% (p=0.002 n=6)
GenerateState-4                             105.2n ± 2%   105.6n ±  0%       ~ (p=0.333 n=6)
GenerateStreetAddress-4                     204.0n ± 1%   206.8n ±  0%  +1.40% (p=0.002 n=6)
GenerateStringPhoneNumber-4                 179.3n ± 0%   179.8n ±  0%       ~ (p=0.058 n=6)
GenerateUnixTimestamp-4                     77.13n ± 1%   78.66n ±  2%  +1.98% (p=0.002 n=6)
GenerateUsername-4                          351.5n ± 0%   355.9n ±  8%  +1.27% (p=0.002 n=6)
GenerateUTCTimestamp-4                      104.2n ± 1%   105.8n ±  1%  +1.49% (p=0.002 n=6)
GenerateUUID-4                              734.0n ± 0%   751.0n ±  3%  +2.32% (p=0.002 n=6)
GenerateZipcode-4                           105.2n ± 2%   106.0n ±  0%       ~ (p=0.084 n=6)
TransformCharacterScramble-4                171.8n ± 1%   171.7n ±  1%       ~ (p=1.000 n=6)
TransformE164PhoneNumber-4                  180.2n ± 3%   180.4n ±  0%       ~ (p=0.974 n=6)
TransformEmail-4                            1.798µ ± 2%   1.816µ ±  0%       ~ (p=0.061 n=6)
TransformFirstName-4                        233.9n ± 0%   235.8n ±  0%  +0.79% (p=0.002 n=6)
TransformFloat64-4                          110.8n ± 4%   110.4n ±  0%       ~ (p=1.000 n=6)
TransformFullName-4                         1.235µ ± 2%   1.242µ ±  1%       ~ (p=0.571 n=6)
TransformInt64-4                            33.74n ± 1%   33.59n ±  0%       ~ (p=0.407 n=6)
TransformInt64PhoneNumber-4                 57.84n ± 2%   57.97n ±  1%       ~ (p=0.619 n=6)
TransformLastName-4                         191.6n ± 0%   194.0n ±  1%  +1.25% (p=0.002 n=6)
TransformString-4                           1.022µ ± 0%   1.026µ ±  1%       ~ (p=0.134 n=6)
TransformStringPhoneNumber-4                211.0n ± 2%   208.9n ±  0%  -0.97% (p=0.002 n=6)
TransformUuid-4                             36.54n ± 1%   36.61n ±  1%       ~ (p=0.675 n=6)
geomean                                     194.0n        194.5n        +0.26%

                                   │ main-benchmark.txt │         branch-benchmark.txt         │
                                   │        B/op        │     B/op      vs base                │
CleanPostgresType-4                        0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=6) ¹
Runner_Single-4                          2.312Ki ± 1%     2.289Ki ± 1%       ~ (p=0.093 n=6)
GenerateBool-4                             0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateBusinessName-4                     304.0 ± 0%       304.0 ± 0%       ~ (p=1.000 n=6) ¹
GenerateCardNumber-4                       8.000 ± 0%       8.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateCategorical-4                      64.00 ± 0%       64.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateCity-4                             160.0 ± 0%       160.0 ± 0%       ~ (p=1.000 n=6) ¹
GenerateCountry-4                          24.00 ± 0%       24.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateEmail-4                            385.0 ± 0%       385.0 ± 0%       ~ (p=1.000 n=6) ¹
GenerateFirstName-4                        208.0 ± 0%       208.0 ± 0%       ~ (p=1.000 n=6) ¹
GenerateFloat64-4                          8.000 ± 0%       8.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateFullAddress-4                      512.0 ± 0%       512.0 ± 0%       ~ (p=1.000 n=6) ¹
GenerateFullName-4                         418.0 ± 0%       418.0 ± 0%       ~ (p=1.000 n=6) ¹
GenerateGender-4                           16.00 ± 0%       16.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateInt64-4                            7.000 ± 0%       7.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateInt64PhoneNumber-4                 8.000 ± 0%       8.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateInternationalPhoneNumber-4         40.00 ± 0%       40.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateIpAddress-4                        31.00 ± 0%       31.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateLastName-4                         176.0 ± 0%       176.0 ± 0%       ~ (p=1.000 n=6) ¹
GenerateRandomString-4                     186.0 ± 0%       186.0 ± 0%       ~ (p=1.000 n=6) ¹
GenerateSHA256Hash-4                       288.0 ± 0%       288.0 ± 0%       ~ (p=1.000 n=6) ¹
GenerateSSN-4                              46.00 ± 0%       46.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateState-4                            24.00 ± 0%       24.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateStreetAddress-4                    240.0 ± 0%       240.0 ± 0%       ~ (p=1.000 n=6) ¹
GenerateStringPhoneNumber-4                40.00 ± 0%       40.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateUnixTimestamp-4                    8.000 ± 0%       8.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateUsername-4                         205.0 ± 0%       205.0 ± 0%       ~ (p=1.000 n=6) ¹
GenerateUTCTimestamp-4                     24.00 ± 0%       24.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateUUID-4                             80.00 ± 0%       80.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateZipcode-4                          24.00 ± 0%       24.00 ± 0%       ~ (p=1.000 n=6) ¹
TransformCharacterScramble-4               40.00 ± 3%       40.00 ± 0%       ~ (p=0.455 n=6)
TransformE164PhoneNumber-4                 40.00 ± 0%       40.00 ± 0%       ~ (p=1.000 n=6) ¹
TransformEmail-4                           489.0 ± 0%       489.0 ± 0%       ~ (p=1.000 n=6) ¹
TransformFirstName-4                       224.0 ± 0%       224.0 ± 0%       ~ (p=1.000 n=6) ¹
TransformFloat64-4                         88.00 ± 0%       88.00 ± 0%       ~ (p=1.000 n=6) ¹
TransformFullName-4                        418.0 ± 0%       418.0 ± 0%       ~ (p=1.000 n=6) ¹
TransformInt64-4                           8.000 ± 0%       8.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformInt64PhoneNumber-4                8.000 ± 0%       8.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformLastName-4                        176.0 ± 0%       176.0 ± 0%       ~ (p=1.000 n=6) ¹
TransformString-4                          202.0 ± 0%       202.0 ± 0%       ~ (p=1.000 n=6) ¹
TransformStringPhoneNumber-4               56.00 ± 0%       56.00 ± 0%       ~ (p=1.000 n=6) ¹
TransformUuid-4                            16.00 ± 0%       16.00 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                               ²                 -0.02%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                   │ main-benchmark.txt │        branch-benchmark.txt        │
                                   │     allocs/op      │ allocs/op   vs base                │
CleanPostgresType-4                        0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
Runner_Single-4                            24.00 ± 0%     24.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateBool-4                             0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateBusinessName-4                     2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateCardNumber-4                       1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateCategorical-4                      2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateCity-4                             2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateCountry-4                          2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateEmail-4                            8.000 ± 0%     8.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateFirstName-4                        2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateFloat64-4                          1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateFullAddress-4                      10.00 ± 0%     10.00 ± 0%       ~ (p=1.000 n=6) ¹
GenerateFullName-4                         6.000 ± 0%     6.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateGender-4                           1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateInt64-4                            0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateInt64PhoneNumber-4                 1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateInternationalPhoneNumber-4         3.000 ± 0%     3.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateIpAddress-4                        2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateLastName-4                         2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateRandomString-4                     3.000 ± 0%     3.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateSHA256Hash-4                       7.000 ± 0%     7.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateSSN-4                              3.000 ± 0%     3.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateState-4                            2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateStreetAddress-4                    2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateStringPhoneNumber-4                3.000 ± 0%     3.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateUnixTimestamp-4                    1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateUsername-4                         6.000 ± 0%     6.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateUTCTimestamp-4                     1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateUUID-4                             3.000 ± 0%     3.000 ± 0%       ~ (p=1.000 n=6) ¹
GenerateZipcode-4                          2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformCharacterScramble-4               2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformE164PhoneNumber-4                 3.000 ± 0%     3.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformEmail-4                           14.00 ± 0%     14.00 ± 0%       ~ (p=1.000 n=6) ¹
TransformFirstName-4                       3.000 ± 0%     3.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformFloat64-4                         3.000 ± 0%     3.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformFullName-4                        6.000 ± 0%     6.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformInt64-4                           1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformInt64PhoneNumber-4                1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformLastName-4                        2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformString-4                          4.000 ± 0%     4.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformStringPhoneNumber-4               4.000 ± 0%     4.000 ± 0%       ~ (p=1.000 n=6) ¹
TransformUuid-4                            1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                               ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

Copy link
Member

@nickzelei nickzelei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work, left a few comments, nothing blocking, just Q's

@@ -708,7 +760,7 @@ BEGIN
SELECT 1
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind = 'i'
WHERE c.relkind in ('i', 'I')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the capital I entail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I = partitioned index

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks postgres that is super clear.

@@ -317,7 +317,7 @@ func (p *PostgresTestContainer) DropSchemas(ctx context.Context, schemas []strin
}

func (p *PostgresTestContainer) GetTableRowCount(ctx context.Context, schema, table string) (int, error) {
rows := p.DB.QueryRow(ctx, fmt.Sprintf("SELECT COUNT(*) FROM ONLY %q.%q;", schema, table))
rows := p.DB.QueryRow(ctx, fmt.Sprintf("SELECT COUNT(*) FROM %q.%q;", schema, table))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, what was the ONLY doing that broke this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I accidentally left that in when I was trying to get inherited tables to work. It was breaking the partitioned tables counts since ONLY ignores any rows that exist in the child tables

Count: destOpts.BatchCount,
Period: destOpts.BatchPeriod,
Count: destOpts.BatchCount,
Processors: []*neosync_benthos.BatchProcessor{sqlProcessor},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe weird diff, but were we basically building the processors but never actually doing anything with them? And now we are?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were only using the processors on insert configs. Now we use the processors on the insert and update configs

@alishakawaguchi alishakawaguchi merged commit c3b6b66 into main Mar 10, 2025
13 of 15 checks passed
@alishakawaguchi alishakawaguchi deleted the alisha/postgres-partition-tables branch March 10, 2025 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants