<@U04S8PLJWMT> how to make sync betweeen postgres ...
# ask-ai
d
@kapa.ai how to make sync betweeen postgres to snowflake fast? billion of rows.
k
To achieve fast syncs between Postgres and Snowflake with billions of rows using Airbyte, consider the following best practices and technical recommendations based on real-world experiences and Airbyte documentation: ### 1. Identify and Address Bottlenecks - Resource Allocation: Ensure your Airbyte deployment (Docker/Kubernetes) has sufficient CPU, memory, and disk. However, simply increasing resources may not always improve sync speed if the bottleneck is at the connector or network level [Optimized Postgres source connector performance](https://discuss.airbyte.io/t/1984). - Monitor Throughput: Use logs and metrics to identify whether the bottleneck is on the source (Postgres), destination (Snowflake), or network. ### 2. Optimize Postgres Source Performance - Indexes: Create indexes on cursor fields (e.g., updated_at, id) in your Postgres tables. This can significantly speed up incremental syncs and reduce failures [Intermittent sync failures from large Postgres table to Snowflake](https://discuss.airbyte.io/t/551). - Replication Method: For very large tables, use [CDC (Change Data Capture)](https://docs.airbyte.com/integrations/sources/postgres#cdc) for incremental syncs. For initial loads, consider using the
xmin
method if your data is under 500GB, or CDC for larger datasets [Low-Latency Data Availability Stack](https://airbyte.com/tutorials/low-latency-data-availability-stack). - Chunking: Airbyte reads large tables in chunks, which helps with reliability and performance [Low-Latency Data Availability Stack](https://airbyte.com/tutorials/low-latency-data-availability-stack). ### 3. Tune Connector and Destination Settings - Buffer Parameter: For the Snowflake destination, increase the buffer parameter (e.g., set to 50) to improve throughput [Postgres CDC connector stuck](https://discuss.airbyte.io/t/4373). - Limit Number of Tables per Connection: If syncing many tables, limit to ~30 tables per connection when using CDC. For more tables, split into multiple connections [Postgres CDC connector stuck](https://discuss.airbyte.io/t/4373). - Staging: Use staging on the Snowflake destination for better performance with large data loads [Postgres CDC connector stuck](https://discuss.airbyte.io/t/4373). ### 4. Airbyte Version and Connector Updates - Upgrade Airbyte and Connectors: Always use the latest versions of Airbyte and its connectors, as performance improvements and bug fixes are released regularly [Optimized Postgres source connector performance](https://discuss.airbyte.io/t/1984). ### 5. Parallelization - Multiple Connections: For multiple tables, create separate Airbyte connections per table to parallelize syncs [Sync performance](https://discuss.airbyte.io/t/1578). ### 6. Storage and Workspace - Sufficient Disk Space: Ensure the Airbyte workspace (WORKSPACE_ROOT) is on a partition with enough space to handle large syncs, as running out of disk can cause incomplete syncs [Postgres to Snowflake only sync part of the data](https://discuss.airbyte.io/t/2188). ### 7. Database Version Compatibility - Database Version: Some issues may be related to the Postgres or Snowflake version (e.g., Aurora Postgres 10.21 had issues with large initial syncs). Upgrading your database may help [Initial load of huge table (>500 GB) fails - Postgres Connector](https://discuss.airbyte.io/t/3694). --- Summary: - Use CDC for incremental syncs and ensure indexes on cursor fields. - Increase buffer size for Snowflake, split large jobs, and use staging. - Upgrade Airbyte and connectors. - Ensure sufficient resources and disk space. - Monitor and address bottlenecks at each stage. If you follow these steps, you can achieve high throughput (e.g., 11 MB/s for Postgres source) and reliably sync billions of rows between Postgres and Snowflake [Low-Latency Data Availability Stack](https://airbyte.com/tutorials/low-latency-data-availability-stack).
d
@kapa.ai 1 table and CDC.
k
A message from kapa.ai
To make syncing a single large Postgres table to Snowflake fast using CDC (Change Data Capture) in Airbyte, here are the key recommendations based on the knowledge sources: 1. Use CDC with Incremental Sync Mode: Configure your Airbyte connection to use CDC and select the Incremental | Append sync mode. With CDC, you do not need to specify a cursor field, as changes are detected via the Debezium connector stream. This ensures only changed rows are synced, not the entire table, which is crucial for performance with billions of rows [Build an EL(T) from Postgres CDC](https://airbyte.com/tutorials/postgresql-change-data-capture-elt#step-5). 2. Optimize Postgres for CDC: - Ensure logical replication is enabled and set up a dedicated replication slot and publication for the table. - Grant the necessary REPLICATION permissions to the Airbyte user. - Use the
pgoutput
plugin for the replication slot [Cloud SQL for PostgreSQL CDC Setup](https://docs.airbyte.com/integrations/sources/postgres/cloud-sql-postgres#setup-using-cdc). 3. Tune Airbyte and Snowflake Settings: - Increase the buffer parameter in the Snowflake destination connector (e.g., set to 50) to improve throughput. - Use staging in the Snowflake destination for better performance with large data loads. - Limit the number of tables per connection to avoid bottlenecks, but since you have only one table, this is not a concern [Forum: Postgres CDC connector stuck](https://discuss.airbyte.io/t/4373). 4. Ensure Sufficient Resources: - Allocate enough CPU, memory, and disk space to your Airbyte deployment. - Make sure your workspace has enough disk space to handle large syncs. 5. Monitor and Upgrade: - Use the latest versions of Airbyte and its connectors for performance improvements and bug fixes. - Monitor sync logs for bottlenecks or errors. Summary: With a single table and CDC, focus on proper CDC setup in Postgres, use Incremental sync mode in Airbyte, tune the Snowflake destination buffer, and ensure your infrastructure can handle the data volume. This approach is proven to deliver high throughput for large tables [Low-Latency Data Availability Stack](https://airbyte.com/tutorials/low-latency-data-availability-stack). If you need step-by-step CDC setup instructions, let me know!
d
Should disk size for kubernetes nodes be big enough @kapa.ai?
k
A message from kapa.ai
Yes, the disk size for Kubernetes nodes running Airbyte should be sufficiently large. According to Airbyte documentation, disk space can become an issue for several reasons: - Long-running syncs can produce a significant amount of logs. - Airbyte connector images, while not massive, can accumulate and use up to 10GBs of disk space in a deployment with multiple connectors. - It is recommended to allocate a minimum of 30GBs of disk space per node. Since storage is relatively inexpensive, it’s better to over-provision to avoid issues during large syncs. This guidance applies specifically to Kubernetes deployments, where you should ensure that your cluster can accommodate the number of pods Airbyte creates and that each node has enough disk space to handle the workload and logs generated by sync jobs [Scaling Airbyte](https://docs.airbyte.com/platform/operator-guides/scaling-airbyte#what-to-scale). In summary: Yes, disk size should be big enough—at least 30GB per node is recommended, and more if you expect to run large or long syncs.
d
@kapa.ai if table 2TB? 🙂
k
A message from kapa.ai
If your table is 2TB in size, you should definitely ensure that your Kubernetes nodes have ample disk space. The Airbyte documentation recommends a minimum of 30GB per node, but for very large tables and long-running syncs, it is wise to provision significantly more than the minimum to avoid running out of space during sync operations. This is especially important because: - Long-running syncs (such as those involving a 2TB table) can generate a large amount of logs. - Multiple connector images and temporary files can quickly consume disk space. - Over-provisioning storage is recommended since storage is relatively inexpensive compared to the risk of sync failures due to insufficient disk space. In summary: For a 2TB table, allocate much more than the 30GB minimum per node—err on the side of over-provisioning to ensure reliability and avoid interruptions during large syncs. The documentation does not specify an exact number for 2TB tables, but emphasizes the importance of having plenty of disk space for large workloads and recommends being generous with your disk allocation for such scenarios [Scaling Airbyte](https://docs.airbyte.com/platform/operator-guides/scaling-airbyte#what-to-scale).