Title: Feature request: Mergable persistance in Postgres tabular · Issue #237 · tinyplex/tinybase · GitHub
Open Graph Title: Feature request: Mergable persistance in Postgres tabular · Issue #237 · tinyplex/tinybase
X Title: Feature request: Mergable persistance in Postgres tabular · Issue #237 · tinyplex/tinybase
Description: Hi, me again, another issue to track and get feedback on what improvements we're doing to our fork of TinyBase and what we'll raise PR to contribute back. Problem / use-case Is your feature request related to a problem? Please describe. ...
Open Graph Description: Hi, me again, another issue to track and get feedback on what improvements we're doing to our fork of TinyBase and what we'll raise PR to contribute back. Problem / use-case Is your feature request...
X Description: Hi, me again, another issue to track and get feedback on what improvements we're doing to our fork of TinyBase and what we'll raise PR to contribute back. Problem / use-case Is your feature...
Opengraph URL: https://github.com/tinyplex/tinybase/issues/237
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature request: Mergable persistance in Postgres tabular","articleBody":"Hi, me again, another issue to track and get feedback on what improvements we're doing to our fork of TinyBase and what we'll raise PR to contribute back.\n\n## Problem / use-case\n_Is your feature request related to a problem? Please describe._\n\nAs docs mention using mergable data structure with tabular store isn't supported in any SQL backed database\n\u003e The following database-oriented [Persister](https://tinybase.org/api/persisters/interfaces/persister/persister/) types can be used to persist a [MergeableStore](https://tinybase.org/api/mergeable-store/interfaces/mergeable/mergeablestore/), but only in the 'JSON-serialization' mode:\n\u003e - PostgresPersister\n\nOur use-case for having this (related to [#236](https://github.com/tinyplex/tinybase/issues/236)) is that especially during migration towards TinyBase we have an existing application that is writing directly to postgres and we want to sync the changes to a store which is then later synced to DurableObjects and to clients.\n\n\n## Feature Request\n**Describe the solution you'd like**\n\ntl;dr: Allow to use `updated_at` column from the table to create approximate HLC during load from DB. ~~But to be able to do that we'd probably need to change HLC logic.~~\n\nI understand that full support is not possible because it would mean storing HLC and the hash for every cell which in tabular mode isn't really possible/practical. However I believe that we can achieve partial support that would be good in 99% of cases and better than having none.\n\n_disclaimer: following is how I understand how it works. And I'm probably wrong_\n\nIf I understand how HLC generally works it has combination of physical time and logical component. And if we could use `updated_at` timestamp from the database as source of physical time we could create an approximate HLC which could be used for merging data together. If we fix the logical counter for approx HLC to 0 we would have a predictable behaviour that in case of 2 writes within same millisecond TinyBase wins. That would work great for us.\n\n~~However, looking through Tinybase [hlc implementation](https://github.com/tinyplex/tinybase/blob/main/src/common/hlc.ts) it seems that it's not using physical time at all. I'm assuming that it's because we can't trust browsers to have correct time set and wrong time could cause completely wrong resolutions. But often HLC implementations have built in protection by checking for back-in-time jumps and adjusting physical time (from wall clock time) to handle that gracefully.~~ _As guessed at in the original write down, I was wrong. The Tinybase HLC implementation uses timestamp_\n\n## Alternatives\n**Describe alternatives you've considered**\nunfortunately we don't see an alternative that would work for us within current TinyBase capabilities. Our main alternative is to completely fork the persister and implement this.\n\n**Additional context**\nThis partially relates to my existing [PR for whereCondition](https://github.com/tinyplex/tinybase/pull/234) and [Feature Request #236](https://github.com/tinyplex/tinybase/issues/236) for partial load of postgres changes but it's not coupled with either of them.\n","author":{"url":"https://github.com/jakubriedl","@type":"Person","name":"jakubriedl"},"datePublished":"2025-04-29T14:55:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/237/tinybase/issues/237"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:868342f1-e3f0-7add-8918-5f19f6e1578f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A26A:2CF315:A0163B:E4A8D0:6A4E43DF |
| html-safe-nonce | c22454737d90d4eacb68764d87b55668b09582f09efc1ed5c347e87f85b835c3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjZBOjJDRjMxNTpBMDE2M0I6RTRBOEQwOjZBNEU0M0RGIiwidmlzaXRvcl9pZCI6IjE3OTg4OTM0ODY4ODA5OTgzNjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6ba6d2bfacda9bfa9f706506cf1a14772ce1239215ad9103146d8eda96003ebe |
| hovercard-subject-tag | issue:3028658813 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/tinyplex/tinybase/237/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dc968bde7016cc50fae554103c3e07109b9396d5f84d72ab0e67d1d1be392fac/tinyplex/tinybase/issues/237 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dc968bde7016cc50fae554103c3e07109b9396d5f84d72ab0e67d1d1be392fac/tinyplex/tinybase/issues/237 |
| og:image:alt | Hi, me again, another issue to track and get feedback on what improvements we're doing to our fork of TinyBase and what we'll raise PR to contribute back. Problem / use-case Is your feature request... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jakubriedl |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/tinyplex/tinybase git https://github.com/tinyplex/tinybase.git |
| octolytics-dimension-user_id | 96894742 |
| octolytics-dimension-user_login | tinyplex |
| octolytics-dimension-repository_id | 443220240 |
| octolytics-dimension-repository_nwo | tinyplex/tinybase |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 443220240 |
| octolytics-dimension-repository_network_root_nwo | tinyplex/tinybase |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9fabff9b8b127e686a3ec86f91422e818056ca2c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width