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 1vkKN0-00Dgja-0P for pgpool-hackers@arkaria.postgresql.org; Mon, 26 Jan 2026 11:02:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vkKMz-007cLD-0u for pgpool-hackers@arkaria.postgresql.org; Mon, 26 Jan 2026 11:02:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vkKMz-007cL5-02 for pgpool-hackers@lists.postgresql.org; Mon, 26 Jan 2026 11:02:57 +0000 Received: from mail-yx1-xb12d.google.com ([2607:f8b0:4864:20::b12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vkKMw-00000000WvC-2prm for pgpool-hackers@lists.postgresql.org; Mon, 26 Jan 2026 11:02:56 +0000 Received: by mail-yx1-xb12d.google.com with SMTP id 956f58d0204a3-649523de977so3837417d50.0 for ; Mon, 26 Jan 2026 03:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769425372; cv=none; d=google.com; s=arc-20240605; b=PK5nt2WV5d9K1n6IZQfKDOE5MXu6TQTLcwID3QndM5OwTOhDP3V72x6UQjC4nwD9ct F9QWvJqTkikQvjITC/ZQMmk4N/AJKs4Liy2vAOktWDQMUlmStl9v9PO7j4gVgbZDFzLt ETisb9gvc8kJG8ibxb0AGorp3BorELlIMQXmpO4+5NICycuzdGRP0T6wqhD79FObweTg hlqrudrWgCjCoKK+LBfyiDbY4a9L4M186g+lBQNGPDbiBsGOOGN9VO2DO08jyJqjPGYM 50/o1PgFfd9u1vJSSRH+UlpcnD5StWzGaQliA3NZEj4KvMldxUQUdRoYGWmH+59ukoLy Uwpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=L82kdd4z4+inHSD0bq+tHL07PM4Jm83O/+OCFTbN9ac=; fh=2jhwfur09QxWKE0iM/zusf3dSNi20nIVx0rRLoSe3Y8=; b=PNg18Hsh8UreFdrpo/e30fmvUqJopZkDOAmKQfC0pPbbTwunERSch81tHv2JNpOsPA q/pneL29+MRMP6vmQF7gNGATLSWjH1d8FGTJ33CAzUsEmHcIX8WZrDH+eafFLCJgTJsS d6CHSxV6ZNec3y07LosFL3L6btPf2Fmx58Q3c0NqmDsA7LwEJhOX/bFuxKTTWF0/oIvY dN9SPFF/DQW3+HQfxaBpGKLAucP2p4aakYGX4SPEe+a8rg3bQbO96WxOaoDRUpz3yDAf cm3VjU6ExA2hlEYE+rVwVFm9XoN1nG3Obah2bNJ867ikpVhTwFycLhr0pBq/5iZ2udcL pIdg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tailorbrands.com; s=google; t=1769425372; x=1770030172; 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=L82kdd4z4+inHSD0bq+tHL07PM4Jm83O/+OCFTbN9ac=; b=D2Wra9frqsSguur0atL3CHH5A7bmvCa2D347sZvcQtG0URfPwHa8aG9h6YyOBHqidV 6uZROAMqCjQ1YJSb+a2u8gLy8pQdJj9J/aSGz02f4xvWYW/F4rbfYfhLHeNplVK0iULb erJmMjRPXvdSa+26jT2TlHftKKa/11LOyTE8hKDFmfxHeoQkOi5uukW9lqAA38rsrGr4 FtYStF0oG3DK2Wz21fA3QMOxcq78F2YyfJIKBx8Lx8X1iAjf5OhEL0Pag6uTNeX/1m6F oaMGt/lSWGhuzI82jukIDleS/JWb/LtkYI6+pc3UcdQkedYU/F4Oco2YPg7BCprK5a7K rglw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769425372; x=1770030172; 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=L82kdd4z4+inHSD0bq+tHL07PM4Jm83O/+OCFTbN9ac=; b=O0OEGu4GXEVjDv6IxPlN4syC6javZ8uqBaDThfBo4bWsi9NSOeZNJ0Cv9nvEneN/Ng jbQkYVgqHx1IU7TWmmjnU2iSNnZ8EtgdxY135t7E7tj+RdCTgLIDUQyZyG72UA+3HsRb 9SbJiEB5INXxWKAr3uB0Ym17N/rrf3IWRtSk+jzjND5Rjd6a6ReHYyFbAL6leA5SPHO1 0mxQSHHe+eadhbyhXACCxbfcfG8LVeRRu5cMcPa7W1N/JaJk7VjWT7xJcBkpM6akOUzm 7G+3bEL49JhOa0ln5F3K0o5NgMamGV6WypNRfFvovoLpYJDebXxRrT5FqQakhnIT7afq 8DHw== X-Gm-Message-State: AOJu0YwUhMdypEBGP+UyLLkdbkp6s5Brp9rNeieTBKhYwotcSUROjHO0 DkZeA6AzJwVMl3sEIrWkiMy1StEce6tFo2qxn+EhJLXL/3LB+mxxH5AAjKjjhoytJzv8MJsSuiV Zn2W6fbA3GlqJY9ao12DjYpthUcrKA8/Rp8oi34+WvKhB2O4u1350wbf3zQ== X-Gm-Gg: AZuq6aJhVaGB9BVUoEEXrkUQzAe1L/5im44JI2m5+KdqtiAaa13klZ002OyTf74xo4N sdcpgw+FwIkihBOiCFAmpe0FBAQ2W7XgonEisJbjP7Ga+6r6UWWg0e4Z2UqRLQ57H67eqBR7kKG n0qFt2nwIuqdeZdz0bqHXiDPpU4MuS1dzYA6reun1lkvI5JLAxpquy2h5HjA0OsOsSiXXxq9sOH rLF0I0KPebWtrVHbvH7qE0f2M7oXTMnj2gV1WdyE3dtCbHD/mlifN33lLMu5qxU7r88Rb+zSjMa vwAUGYqMnQ1J4YN+rKrn8Uf+0qmPLJ52FkQDOXpsljk9rxRBortu7YXpOX+/8nM4l3WF X-Received: by 2002:a05:690e:118e:b0:640:b8ef:b777 with SMTP id 956f58d0204a3-64970d0d68bmr2955864d50.69.1769425372010; Mon, 26 Jan 2026 03:02:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Nadav Shatz Date: Mon, 26 Jan 2026 13:02:40 +0200 X-Gm-Features: AZwV_QjjoBYGY3lsiK4ukZsm4_v-nocg_YuDTbE3imp6c_oeF4HfVqtn7S5s2hg Message-ID: Subject: Re: Proposal: Recent mutated table tracking in memory To: pgpool-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000c17ca306494872b7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c17ca306494872b7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Doing another ping - sorry for that, it's been 20 days. Would appreciate any feedback. thank you On Wed, Jan 14, 2026 at 10:55=E2=80=AFAM Nadav Shatz wrote: > 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 addin= g >> here a patch to implement tracking of latest mutated table, and then usi= ng >> the replication lag as a base - deciding where to point queries when que= ry >> load balancing and parsing is enabled. >> >> More details as in the patch: >> Feature: add in-memory table tracking to prevent stale reads from replic= as >> >> 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 facto= r >> - 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 >> > > > -- > Nadav Shatz > Tailor Brands | CTO > --=20 Nadav Shatz Tailor Brands | CTO --000000000000c17ca306494872b7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Doing another ping - sorry for that, it's been 20 days= .

Would appreciate any feedback. thank you
On Wed, Jan 14, 2026 at 10:55=E2=80=AFAM Nadav Shatz <nadav@tailorbrands.com> wrot= e:
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 <nadav@tailorbrands.com= > wrote:
=
Hello,

As initially proposed= under "Proposal: recent access based routing for primary-replica setu= ps" and then broken into separate=C2=A0tasks - i am adding here a patc= h to implement tracking of latest mutated table, and then using the replica= tion lag as a base - deciding where to point queries when query load balanc= ing and parsing is enabled.

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

Implement "memory map" feature that trac= ks recently-written database
tables in shared memory to prevent stale re= ads during replication lag.
When a write (INSERT/UPDATE/DELETE) occurs o= n 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 LR= U eviction for performance
- Cold start protection (routes all queries t= o primary initially)
- Automatic TTL calculation: replication_delay =C3= =97 configurable factor
- Per-table staleness tracking with microsecond = precision

New configuration parameters:
- memory_map_enabled: Ena= ble/disable the feature (default: off)
- memory_map_ttl_factor: TTL mult= iplier for replication delay (default: 5.0)
- memory_map_cold_start_dura= tion: Cold start period in ms (default: 2000)
- memory_map_table_buckets= : Hash buckets for table map (default: 1024)
- memory_map_table_size: Ma= x tracked tables (default: 2048)
- memory_map_query_buckets: Hash bucket= s for query cache (default: 2048)
- memory_map_query_cache_size: Max cac= hed queries (default: 10000)

Patch applies properl= y and tests pass.

Open to all feedback - thank you= !

--
=
Nadav Sh= atz
Tailor Brands=C2= =A0| CTO


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


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