0Pricing
Advanced PostgreSQL: Indexing, Partitioning, Replication · درس

فك الترميز المنطقي والتقاط تغيّرات البيانات

استخدم فك الترميز المنطقي لبث التغيّرات على مستوى الصفوف من PostgreSQL إلى مسارات CDC والأنظمة القائمة على الأحداث.

فك الترميز المنطقي والتقاط تغيّرات البيانات درس مجاني في Advanced PostgreSQL: Indexing, Partitioning, Replication على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Advanced PostgreSQL: Indexing, Partitioning, Replication، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Advanced PostgreSQL: Indexing, Partitioning, Replication 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

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.

الأسئلة الشائعة

هل درس «فك الترميز المنطقي والتقاط تغيّرات البيانات» مجاني؟

نعم — نص درس «فك الترميز المنطقي والتقاط تغيّرات البيانات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Advanced PostgreSQL: Indexing, Partitioning, Replication، انتقل إلى CoddyKit PRO. تتضمن دورة Advanced PostgreSQL: Indexing, Partitioning, Replication 4 دروس في المجموع.

ماذا ستتعلم في «فك الترميز المنطقي والتقاط تغيّرات البيانات»؟

استخدم فك الترميز المنطقي لبث التغيّرات على مستوى الصفوف من PostgreSQL إلى مسارات CDC والأنظمة القائمة على الأحداث. تتمرن على Advanced PostgreSQL: Indexing, Partitioning, Replication مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Advanced PostgreSQL: Indexing, Partitioning, Replication؟

لا تُشترط خبرة سابقة. Advanced PostgreSQL: Indexing, Partitioning, Replication على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «فك الترميز المنطقي والتقاط تغيّرات البيانات»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Advanced PostgreSQL: Indexing, Partitioning, Replication هذا؟

نعم. كل درس في Advanced PostgreSQL: Indexing, Partitioning, Replication يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. النسخ المتماثل المتسلسل
  2. النسخ المتماثل متعدد الرؤساء (BDR)
  3. فتحات النسخ المتماثل وإدارة WAL
  4. فك الترميز المنطقي والتقاط تغيّرات البيانات
← العودة إلى Advanced PostgreSQL: Indexing, Partitioning, Replication