Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vfwfU-006KC6-1a for pgpool-hackers@arkaria.postgresql.org; Wed, 14 Jan 2026 08:55:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vfwfT-0098iw-2P for pgpool-hackers@arkaria.postgresql.org; Wed, 14 Jan 2026 08:55:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vfwfT-0098im-1N for pgpool-hackers@lists.postgresql.org; Wed, 14 Jan 2026 08:55:55 +0000 Received: from mail-yx1-xb130.google.com ([2607:f8b0:4864:20::b130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vfwfQ-000Lky-2k for pgpool-hackers@lists.postgresql.org; Wed, 14 Jan 2026 08:55:54 +0000 Received: by mail-yx1-xb130.google.com with SMTP id 956f58d0204a3-6442e2dd8bbso6632326d50.0 for ; Wed, 14 Jan 2026 00:55:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tailorbrands.com; s=google; t=1768380953; x=1768985753; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=F9m2pXZZaih0gKdO0kH2JwWWnX7x9iZlfi1LxTgSL5o=; b=POcHvBvRfQSqCO5kwXgqD6Mo6AB1BHDkb8BUWmqGuM3hLDTRRm7PWVVNlm0pqxTFcd q4A9rU++hqGDytNj5OExkf8ocPT4UIwB8pPOAE3FNKn0P5xl3GcTStCEFj2k0VEp2dZE CFtXoyJoIW72FUxK3sDKPzXOwEkxIAdSDMPOGXBk0R3lbKTG/Hr2rLNUZmLtYh+A0J9c Bz0WchvX+aOWTr4SpYdGGjjAwDVJ0EcDR40p+q0bZ6MymGEwDLJa5Fqrjfr2Uii/kuQP ihu50BrOBVBCwzb1C9MLhldZ4sHSbeblZmfVxiRvu+W2skrzaBt4H/wg1hbUl4NT2SCz HgbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768380953; x=1768985753; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=F9m2pXZZaih0gKdO0kH2JwWWnX7x9iZlfi1LxTgSL5o=; b=QIXG1oRE0ITim6KAu4CfhQ/W4WnkYTVXZiHAGE1eOCdLAL6BYEmp+BID0R5b/KrZPD iRUBXGnACkr15C40PfkTEyck3kZprfoeaC3NASitmVldsjceqnpHhXUBHowAvVO2A4dB +eheCTxtK4YdSjJ61+QU5cNJieeNJ23PihuZX7xr8HiijiX+H9yX5sXIPiq8gwDxbC0r fxkyWInhp4rTs3UYaw2hSVt7tcUdacj4v9CtQ3AHj+XuyWT5hT7NJJ0vbkKruKCXy2EL CJmPCblr5bH9EOuJkZWZ8gCWk0OZYR/my6RiaC3gRYQ5ukcZfwTHJ9KKbnS7zRdFDZm2 ik9Q== X-Gm-Message-State: AOJu0YwNH+Ch+FZOZiK0VEBUYAdNngsirN0iVFK0QFvSr2OJxwNns6kP KJq5UdblUfEldc+4HZmd8IJ0UC7VT9I7SJCHdoHAp4R4IAXJGNw7vhfi97oaqwv8AJH9IL23B8w KQUUytdjC51/L6hpHhOyiWxJy41c4QsNzyhgdJ92DryBaGYSEcyfIEt6m2A== X-Gm-Gg: AY/fxX7VwtDYmri1tCZvRXjU7PPxzayYUJgaLQa+SZhCQLwdSVK+2a4Om9IjrwriBX4 mqSz3N4gbi4hN6wA9sM9xhSeL1IxYMpdv9P1l/cBtVqXvVAjdMru/wMMmXLx6OWRIB958bRkJk7 kvMMmWGGVkTVjleMuOjtq1aoQNv5XDNGVLJ1VdhQ04aZ9oNhsSyNDG7KNYTnW5YylGvP8M7cPv/ Hcgkf4RaIxpQFJTPBLMQpWvEzlcmZuKo3rpZbT4cgYFC4KFz5x1Fnhc489Cw627vLSxstSVMD7b na9tiONSPmEoFtIOGEZp3NT2TNZt2ota5JFJDFZiPOalzy2/RcyXZhcNjG9Zs9dZf3di X-Received: by 2002:a05:690e:138e:b0:647:101f:cc66 with SMTP id 956f58d0204a3-64901b1ad77mr1473083d50.73.1768380952668; Wed, 14 Jan 2026 00:55:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Nadav Shatz Date: Wed, 14 Jan 2026 10:55:41 +0200 X-Gm-Features: AZwV_Qi8bOIcA_7Vz9kX5Gj1qq9YU3CQ4R3yjgXEGVJbL1liYqC8wd70tH86EAA Message-ID: Subject: Re: Proposal: Recent mutated table tracking in memory To: pgpool-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000830d0606485546cd" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000830d0606485546cd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi all, Any comments or concerns? can we merge it if not? On Tue, Jan 6, 2026 at 1:25=E2=80=AFPM Nadav Shatz = wrote: > Hello, > > As initially proposed under "Proposal: recent access based routing for > primary-replica setups" and then broken into separate tasks - i am adding > here a patch to implement tracking of latest mutated table, and then usin= g > the replication lag as a base - deciding where to point queries when quer= y > load balancing and parsing is enabled. > > More details as in the patch: > Feature: add in-memory table tracking to prevent stale reads from replica= s > > Implement "memory map" feature that tracks recently-written database > tables in shared memory to prevent stale reads during replication lag. > When a write (INSERT/UPDATE/DELETE) occurs on a table, that table is > marked as "dirty" for a configurable TTL period. Any SELECT on a dirty > table within the TTL window is routed to primary instead of replica. > > Key features: > - Shared memory hash table for tracking table mutations with TTL > - Query parse cache with LRU eviction for performance > - Cold start protection (routes all queries to primary initially) > - Automatic TTL calculation: replication_delay =C3=97 configurable factor > - Per-table staleness tracking with microsecond precision > > New configuration parameters: > - memory_map_enabled: Enable/disable the feature (default: off) > - memory_map_ttl_factor: TTL multiplier for replication delay (default: > 5.0) > - memory_map_cold_start_duration: Cold start period in ms (default: 2000) > - memory_map_table_buckets: Hash buckets for table map (default: 1024) > - memory_map_table_size: Max tracked tables (default: 2048) > - memory_map_query_buckets: Hash buckets for query cache (default: 2048) > - memory_map_query_cache_size: Max cached queries (default: 10000) > > Patch applies properly and tests pass. > > Open to all feedback - thank you! > > -- > Nadav Shatz > Tailor Brands | CTO > --=20 Nadav Shatz Tailor Brands | CTO --000000000000830d0606485546cd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi all,

Any comments or concerns? can w= e merge it if not?

On Tue, Jan 6, 2026 at 1:25= =E2=80=AFPM Nadav Shatz <nadav= @tailorbrands.com> wrote:
Hello,

As i= nitially proposed under "Proposal: recent access based routing for pri= mary-replica setups" and then broken into separate=C2=A0tasks - i am a= dding here a patch to implement tracking of latest mutated table, and then = using the replication lag as a base - deciding where to point queries when = query load balancing and parsing is enabled.

More = details as in the patch:
Feature: add in-memory table tracking to= prevent stale reads from replicas

Implement "memory map" = feature that tracks recently-written database
tables in shared memory to= prevent stale reads during replication lag.
When a write (INSERT/UPDATE= /DELETE) occurs on a table, that table is
marked as "dirty" fo= r a configurable TTL period. Any SELECT on a dirty
table within the TTL = window is routed to primary instead of replica.

Key features:
- S= hared memory hash table for tracking table mutations with TTL
- Query pa= rse cache with LRU eviction for performance
- Cold start protection (rou= tes all queries to primary initially)
- Automatic TTL calculation: repli= cation_delay =C3=97 configurable factor
- Per-table staleness tracking w= ith microsecond precision

New configuration parameters:
- memory_= map_enabled: Enable/disable the feature (default: off)
- memory_map_ttl_= factor: TTL multiplier for replication delay (default: 5.0)
- memory_map= _cold_start_duration: Cold start period in ms (default: 2000)
- memory_m= ap_table_buckets: Hash buckets for table map (default: 1024)
- memory_ma= p_table_size: Max tracked tables (default: 2048)
- memory_map_query_buck= ets: Hash buckets for query cache (default: 2048)
- memory_map_query_cac= he_size: Max cached queries (default: 10000)

Patch= applies properly and tests pass.

Open to all feed= back - thank you!

--
Nadav Shatz
Tail= or Brands=C2=A0| CTO


--
Nadav Shatz
<= font color=3D"#000000">Tailor Brands=C2=A0| CTO
--000000000000830d0606485546cd--