0Pricing
Advanced PostgreSQL: Indexing, Partitioning, Replication · Lektion

Logische Dekodierung und Change Data Capture

Nutzen Sie die logische Dekodierung, um Änderungen auf Zeilenebene aus PostgreSQL für CDC-Pipelines und ereignisgesteuerte Systeme zu streamen.

Logische Dekodierung und Change Data Capture ist eine kostenlose Advanced PostgreSQL: Indexing, Partitioning, Replication-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Advanced PostgreSQL: Indexing, Partitioning, Replication-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Advanced PostgreSQL: Indexing, Partitioning, Replication-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

What Is Logical Decoding

Logical decoding turns the write-ahead log into a readable stream of logical row changes. It is the foundation of both logical replication and external Change Data Capture (CDC).

Output Plugins

A plugin decides the format of the change stream. Built-in pgoutput powers logical replication; test_decoding emits human-readable text; tools like Debezium use their own.

Prerequisite: wal_level

Logical decoding needs wal_level = logical. Changing it requires a restart.

-- postgresql.conf
wal_level = logical

Creating a Logical Slot

A logical replication slot tracks how far a consumer has read and prevents WAL needed by it from being removed.

SELECT pg_create_logical_replication_slot(
  'cdc_slot', 'test_decoding');

Peeking at Changes

pg_logical_slot_peek_changes shows pending changes without advancing the slot, useful for inspection.

SELECT * FROM pg_logical_slot_peek_changes(
  'cdc_slot', NULL, NULL);

Consuming Changes

pg_logical_slot_get_changes reads and advances the slot, so those changes will not be returned again.

SELECT * FROM pg_logical_slot_get_changes(
  'cdc_slot', NULL, NULL);

Example Change Output

With test_decoding an INSERT appears as readable text describing the table and new column values, wrapped between BEGIN and COMMIT markers.

BEGIN 712
table public.users: INSERT: id[int]:1 name[text]:'Ada'
COMMIT 712

Slots Hold WAL

An inactive slot keeps WAL forever, which can fill the disk. Monitor and drop unused slots.

SELECT slot_name, active FROM pg_replication_slots;
SELECT pg_drop_replication_slot('cdc_slot');

CDC Pipelines

External CDC connectors stream from a slot into systems like Kafka, search indexes, or data warehouses, enabling near-real-time downstream updates.

At-least-once Delivery

Consumers must track the last confirmed LSN and handle possible re-delivery after a crash. Design downstream writes to be idempotent.

Replica Identity for CDC

To capture the full before image on updates and deletes, set REPLICA IDENTITY FULL on tables without a usable primary key.

ALTER TABLE orders REPLICA IDENTITY FULL;

Quick Check

Why must logical replication slots be monitored?

Recap

You learned logical decoding: set wal_level=logical, create a logical slot with an output plugin, peek or consume changes, and feed CDC pipelines. Monitor slots, design idempotent consumers, and set replica identity for full change images.

Häufig gestellte Fragen

Ist die Lektion „Logische Dekodierung und Change Data Capture“ kostenlos?

Ja — der vollständige Text von „Logische Dekodierung und Change Data Capture“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Advanced PostgreSQL: Indexing, Partitioning, Replication-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Advanced PostgreSQL: Indexing, Partitioning, Replication-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Logische Dekodierung und Change Data Capture“?

Nutzen Sie die logische Dekodierung, um Änderungen auf Zeilenebene aus PostgreSQL für CDC-Pipelines und ereignisgesteuerte Systeme zu streamen. Du übst Advanced PostgreSQL: Indexing, Partitioning, Replication mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Advanced PostgreSQL: Indexing, Partitioning, Replication zu starten?

Keine Vorkenntnisse erforderlich. Advanced PostgreSQL: Indexing, Partitioning, Replication auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Logische Dekodierung und Change Data Capture“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Advanced PostgreSQL: Indexing, Partitioning, Replication-Lektion Code schreiben und ausführen?

Ja. Jede Advanced PostgreSQL: Indexing, Partitioning, Replication-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Kaskadierende Replikation
  2. Multi-Master-Replikation (BDR)
  3. Replikations-Slots und WAL-Verwaltung
  4. Logische Dekodierung und Change Data Capture
← Zurück zu Advanced PostgreSQL: Indexing, Partitioning, Replication