News for hackers. Stuff that matters.
Re:Implementing system-versioned tables in Postgres by adamcharnock on Wednesday February 07, 2024 @04:08AM (#39286240)
> Now, there are extensions out there that implement versioning – temporal_tables being the most popular I think – but none are supported for managed Postgres instances on e.g. Azure or AWS. This means that if we want system-versioned tables, we’re forced to make it ourselves.

This really provokes a wild geek rage inside me. Not that it is untrue, but that this is the state of things. It's that cloud providers are now often seen as the only responsible way to operate infrastructure, and in the process we hand over so much control of our tooling. We let ourselves be convinced that simplicity was worth a 10x premium, and admitted we were not grown up enough to handle the tools we had made for ourselves.

Sure, I know it is more complex than that. But I also feel sad about it.

Re:Implementing system-versioned tables in Postgres by devnonymous on Wednesday February 07, 2024 @04:29AM (#39286403)
Exactly ! What's worse that we seem to have developed this all-in-or-none-at-all approach towards cloud services. Whatever happened to a hybrid approah of using the cloud only for things that you wanted ?
Re:Implementing system-versioned tables in Postgres by cqqxo4zV46cp on Wednesday February 07, 2024 @07:55AM (#39287956)
A database is near the top of most people’s list for things that they don’t want to manage themselves. This rant is verging on irrelevant.
Re:Implementing system-versioned tables in Postgres by sroussey on Wednesday February 07, 2024 @10:11AM (#39289490)
I used to have some MySQL servers running for so many years that I was afraid to restart the machines.
Re:Implementing system-versioned tables in Postgres by DaiPlusPlus on Wednesday February 07, 2024 @10:30AM (#39289736)
> manage themselves.

Be careful with the language there....

I assume you meant that no-one wants to have to run and administer an RDBMS like Postgres, MSSQL, Oracle, etc - especially not things like backups, restoration, disaster-recovery, figure out storage, ensure high-availability, and maybe even things like user administration and index management: i.e. a DBA's grunt-work - and yes, I agree with you entirely.

...but using the other interpretation of "manage", people might think you meant that people don't want to know how to properly design a normalized schema and apply the business-domain, knowing how to clean-up data appropriately (i.e. the other half of a DBA's job), because we can either shove it all into a cloud vendor's proprietary (and horrendously expensive) non-relational database or data-lake solution (CosmosDB, etc) - or that we can outsource database modelling and implementation of DDL to an LLM - which I'll admit, is quite capable as-is for a first-draft for DB scaffolding and getting better all the time, but ultimately isn't able to take a proactive or autonomous approach to managing an org's databases; I don't want to seem like I'm advocating economic-protectionism of DBAs, but I get the impression LLM-based DBA-bots are being aggressively pitched to smaller-sized orgs that don't know any better, at a time when the technology is still very new, with potentially serious repercussions w.r.t. data-security and compliance (and ChatGPT still gives me T-SQL that uses Oracle functions...).

Re:Implementing system-versioned tables in Postgres by nyrikki on Wednesday February 07, 2024 @01:48PM (#39292545)
Most people I interact with are targeting CQRS as the CRUD model is what most people use. The problem with the DB central approach is many faceted as as most people really just need a repository the inherent problems testing, vertical scaling, availability, typical default of procedural cohesion etc... is why people don't care.

The self managed DB servers aren't cheap once you have to scale, typically have availability issues due to ACID rules typically limiting servers to only two AZ's per region etc...

It is actually adopting best practices for software maintainability and scalability that are getting rid of most DBA needs....because most databases use aren't doing batch processing, report generation, backups, job scheduling, or other needs that tend to be the right use cases for relational databases.

Concepts like encapsulation, persistence ignorance, and other methods of ensuring that the persistence layer is as loosely coupled as possible have proven to be cheaper, easier to test, and avoid the lock in you mention above.

As i have had a professional relationship with AWS/GCS here are a few anti-patterns from Microsoft that demonstrate this.

https://learn.microsoft.com/en-us/azure/architecture/antipat... https://learn.microsoft.com/en-us/azure/architecture/antipat... https://learn.microsoft.com/en-us/azure/architecture/antipat...

I made a good living as a consultant in the .com era helping companies throw money at their foreign key loving branching stored procedure systems that they couldn't even get to scale past the angel round some times.

And entire companies like AT&T wireless went under in a large part due to failed upgrades due to issues related to having logic in the DB.

DBs can be a good persistence layer when a system is simple and small. But really to work well within a cloud or distributed context they need to be treated as repositories unless there is a compelling technical reason to treat them differently.

'When all you have is a hammer' approach monolithic persistence layer what the primary blocker when I worked with cloud providers to help customers migrate. And they always were paranoid of moving things out of the database. And the funny thing is that most of them were trying to move to the cloud because vertical scaling on-prem DB servers became too expensive and didn't deliver the performance vendors promised.

Had companies followed say the design patterns of micro-services, where each service context has it's own DB, they probably could have stayed on-prem at lower costs.

But for the clients I worked with, who had failed to migrate on their own. Complex fragile schemas, triggers, sp's, etc... where almost always the main issue.

And we knew this even before the commercial internet existed.

Re:Implementing system-versioned tables in Postgres by refset on Wednesday February 07, 2024 @04:34AM (#39286432)
It's especially tragic knowing that Postgres did originally have system-time-like versioning built-in. Instead we get to enjoy being upsold on proprietary ETL-to-Redshift, AlloyDB, etc.
Re:Implementing system-versioned tables in Postgres by ttfkam on Wednesday February 07, 2024 @05:44PM (#39295353)
Citation needed? There have been one-off, incomplete iterations in extensions, but core and contrib have never had this.
Re:Implementing system-versioned tables in Postgres by refset on Wednesday February 07, 2024 @06:12PM (#39295605)
I have never researched the timeline properly to understand at which point the concept/code got ditched, but it was part of Stonebraker's 1985 vision: https://dsf.berkeley.edu/papers/ERL-M85-95.pdf

> POSTQUEL allows users to save and query historical data and versions. By default, data in a relation is never deleted or updated. Conventional retrievals always access the current tuples in the relation. Historical data can be accessed by indicating the desired time when defining a tuple variable.

I looked this up during another thread which also has some other sources if you want to dig further: https://news.ycombinator.com/item?id=37956687

Re:Implementing system-versioned tables in Postgres by ttfkam on Wednesday February 07, 2024 @08:39PM (#39296793)
So pre-PostgreSQL then.
Re:Implementing system-versioned tables in Postgres by refset on Thursday February 08, 2024 @03:53AM (#39299803)
I would guess so, yes.
Re:Implementing system-versioned tables in Postgres by krab on Thursday February 08, 2024 @06:19AM (#39300670)
Re:Implementing system-versioned tables in Postgres by ttfkam on Thursday February 08, 2024 @08:18PM (#39310201)
Thanks! I had used 6.0. I was totally unaware this was an option at the time. For what it was worth, Postgres was dog slow back then.
Re:Implementing system-versioned tables in Postgres by zer00eyz on Wednesday February 07, 2024 @04:56AM (#39286567)
>>> It's that cloud providers are now often seen as the only responsible way to operate infrastructure

23 billion.

Thats the profit for AWS in 2023.

23 billon that AWS users pissed away.

AWS is NOT cheap. I have quite a few clients who, could save lots of money dumping their cloud provider and setting up their own racks, hiring SA's. I have others who, if they optimized any of their stack could cut their AWS bills by half.

Having survived the 2000 bubble the lessons are going to have to be re-learned. Everything has cost and value and managing that is going to become an engineering task in the near future.

Re:Implementing system-versioned tables in Postgres by Cthulhu_ on Wednesday February 07, 2024 @07:17AM (#39287638)
I mean AWS optimization is a valid consultancy/self employment career; it's like tech debt in coding, you make it work first, prove that it works, get value from it, and only then look into optimizing.

Would these clients have been able to make the upfront investment to set up their own racks and hire / train the relevant staff? That's the sales pitch for AWS and other cloud providers, you can get started a lot faster, make money, only then look into optimizing.

Running your own servers is easy to underestimate. Running it with the reliability, backup and fallbacks that cloud providers offer is also easily overlooked. How much does it cost to set up a multi region cluster yourself?

That said, there are some real life examples of companies that moved away from AWS in favor of their own servers, like Dropbox which bootstrapped on AWS, then built their own eight years later (https://techcrunch.com/2017/09/15/why-dropbox-decided-to-dro...).

Re:Implementing system-versioned tables in Postgres by sgarland on Wednesday February 07, 2024 @08:41AM (#39288412)
> you can get started a lot faster, make money, only then look into optimizing.

IME, companies often will first fall into the trap of minimum spend with AWS for larger discounts, such that even when you _do_ try to optimize things, it doesn’t matter. There is no greater disincentive than saving 5 digits per month, only to be told “thanks, but it doesn’t matter.”

Tangentially, I think the rise of cloud and SaaS to blame more than anything for the I-shaped engineer. Why bother learning anything about optimization when K8s will silently add another node to the cluster as needed? Why bother learning SQL when ORMs abound, and your Serverless DB will happily upsize to deal with your terrible schema? After all, you’re being told to ship, ship, ship, so there’s not really any time to learn those things anyway.

I simultaneously love and hate cloud providers, and am eagerly awaiting the slow but steady turn towards on-prem/colo. 37Signals has the right idea.

Re:Implementing system-versioned tables in Postgres by pdimitar on Wednesday February 07, 2024 @07:56AM (#39287963)
> Everything has cost and value and managing that is going to become an engineering task in the near future.

FYI: I have known people 8 years ago who already made money by optimizing people's AWS bills. "AWS expert", "AWS consultant" etc. are valid contractor titles.

Re:Implementing system-versioned tables in Postgres by Rapzid on Wednesday February 07, 2024 @05:41AM (#39286891)
Business transactions aren't zero sum.
Re:Implementing system-versioned tables in Postgres by troupo on Wednesday February 07, 2024 @07:24AM (#39287689)
> AWS is NOT cheap.

I've realised that cloud costs are a "wave". (App is app/service/business)

- cheap to run as a small app

- costly to run as a bigger app, cheaper to self-host

- cheaper than running all infra for a much bigger app

- extremely costly compared to running all infra for a much-much bigger app

- probably on par with running your own infra (but then you're getting into tens/hundreds of millions of customers)

Re:Implementing system-versioned tables in Postgres by cqqxo4zV46cp on Wednesday February 07, 2024 @07:54AM (#39287943)
You can sit here calling “profit” pissing money away until you’re on the receiving end of it. Then you’ll be going on about the value you’re providing. Stop being dramatic.
Re:Implementing system-versioned tables in Postgres by jjice on Wednesday February 07, 2024 @09:34AM (#39289032)
> 23 billon that AWS users pissed away.

While I agree that running your own hardware can be _seriously_ cheaper, this is like saying that renting is a waste of money and everyone should purchase a home.

Capacity planning isn't easy for a lot of small companies. Neither is the engineering time to set up, manage, and troubleshoot the hardware. At a certain scale, these are no brainers to take into your own hands, but for a 15 person engineering team that's completely focused on the product, it would be pretty expensive in human cost to set up and manage your own hardware. Sometimes, it can be set-and-forget, but rarely will it be as set-and-forget as a cloud provider.

Is it more expensive overall? Yes. Is it "pissed away" money? In some cases, maybe. In many, no. The ease of running and reduced upfront capex is absolutely valuable.

Re:Implementing system-versioned tables in Postgres by sroussey on Wednesday February 07, 2024 @10:07AM (#39289443)
I used to setup a rack for a two person engineering team. It does take focus away sometimes. Particularly if the Colo lost A/C… but thankfully that’s not really an issue these days.
Re:Implementing system-versioned tables in Postgres by yellowapple on Wednesday February 07, 2024 @04:10PM (#39294366)
> this is like saying that renting is a waste of money and everyone should purchase a home

Renting is a waste of money and everyone (or at least a lot more people than at present) should own one's own home, whether on their own or via e.g. a housing cooperative.

Re:Implementing system-versioned tables in Postgres by drstewart on Wednesday February 07, 2024 @05:24PM (#39295126)
Everyone doesn't have the same goals as you and putting things in italics doesn't make you right
Re:Implementing system-versioned tables in Postgres by yellowapple on Wednesday February 07, 2024 @09:35PM (#39297197)
It ain't the italics that make me right, but the things I write :)
Re:Implementing system-versioned tables in Postgres by erhaetherth on Thursday February 08, 2024 @12:46AM (#39298696)
There was a good rent vs buy calculator I found years ago, not sure which one it was, but it doesn't even make financial sense in some scenarios, particularly for shorter terms.
Re:Implementing system-versioned tables in Postgres by zeroimpl on Wednesday February 07, 2024 @10:20PM (#39297610)
While renting does typically cost more than owing, from a purely financial perspective, in practice you can argue that the difference is simply what you are paying the landlord for the services they are providing. The landlord is responsible for maintenance, taxes, insurance, and more. Not everybody wants to deal with those things. The landlord might be more efficient at those things too, especially in a rental apartment.

AWS might cost more but it provides a lot of benefits that are hard to assign a dollar value to.

Re:Implementing system-versioned tables in Postgres by yellowapple on Friday February 09, 2024 @05:24AM (#39313393)
> The landlord is responsible for maintenance, taxes, insurance, and more.

Those things are typically factored into estimates for ownership v. rental costs, and even with those factored in, renting costs more than owning. That really shouldn't be terribly surprising, either; if landlords only broke even on their rentals, then there would be no reason to be in the rental business instead of the property management business.

Re:Implementing system-versioned tables in Postgres by jjice on Thursday February 08, 2024 @09:15AM (#39302133)
As some of the sibling comments have said, owning a home can be great if it's over a certain period of time and you know what you want, kind of like capacity planning. If you don't know what you need or you're not sure you're going to use it long term, renting can make sense (like the situation where AWS is a valuable use case).

If I know I'm going to be living in a city for two years, buying a home would likely be a bad idea. Sure we could talk about scenarios of renting it out and yada yada, but we're getting into corner cases in a comment section of a thread about AWS pricing :)

Re:Implementing system-versioned tables in Postgres by yellowapple on Friday February 09, 2024 @05:36AM (#39313455)
Right, but how many people know they're only going to be in a city for two years? Most people intend to be in a place long-term; moving is in and of itself relatively expensive (even more so the further you move) and tends to be avoided unless there's good reason to do so or unless there's no other option.

And bringing things back to AWS pricing: yeah, at first you might not know exactly what you need capacity-wise, but at some point (assuming you're actually measuring resource usage) you start to get a feel for what you need day-to-day and where things are trending. Much like with living arrangements, infrastructure hosting tends to have at least some pieces that you know you're gonna need long-term.

The more compelling reason to go with IaaS/PaaS is the convenience of not needing to run your own servers in your own rack - and it's that convenience that you're paying for, at a premium compared to hiring sysadmins. For a lot of businesses that's cost-effective, because they don't have/need enough infra to keep a sysadmin busy, but at some point that flips.

Re:Implementing system-versioned tables in Postgres by JAlexoid on Wednesday February 07, 2024 @03:04PM (#39293551)
How much would be pissed away on duplicating DBMS administration work?

Are we that far removed from reality to forget that one small team of DB admins can handle literally thousands of instances?

We use AWS because collectively paying AWS 23billion is stupendously cheaper than 1m users AWS having a a whole infrastructure team.

Re:Implementing system-versioned tables in Postgres by acchow on Wednesday February 07, 2024 @05:38PM (#39295281)
> 23 billon that AWS users pissed away.

How do you know it would have cost them less to hire their own teams for self-hosting?

Re:Implementing system-versioned tables in Postgres by olavgg on Wednesday February 07, 2024 @04:59AM (#39286592)
I don't feel sad at all, I feel my competition is slacking and that is my benefit.
Re:Implementing system-versioned tables in Postgres by verticalscaler on Wednesday February 07, 2024 @05:12AM (#39286694)
For a small greenfield project rolling your own Postgres is a very viable option with attractive trade offs for some. If it is now considered rarefied knowledge in your circles you should be glad as this might a competitive advantage.

Let the other startups spend x10-100 on their resume driven development and blaze through their runway. Common story actually.

But suppose you don't need it and RDS as-is covers all your needs, which it often does, why rage? This is a continuum.

If an early decision to punt and outsource it to the cloud was made it could always be reversed at an opportune moment. I don't think competent people see it as "the only way" just the most common and pragmatic option.

Re:Implementing system-versioned tables in Postgres by cpursley on Wednesday February 07, 2024 @11:02AM (#39290153)
For a small project (assuming the goal is profitability), rolling your own Postgres seems mighty distracting.
Re:Implementing system-versioned tables in Postgres by hobs on Wednesday February 07, 2024 @09:09AM (#39288750)
eh, in my experience system managed temporal tables are crap anyway, they have a specific set of circumstances built in and anytime you break out of those you basically have to design your own trigger based solution anyway.
Re:Implementing system-versioned tables in Postgres by DaiPlusPlus on Wednesday February 07, 2024 @10:44AM (#39289912)
Can you give some examples of the problems you've had with them?

We use SQL Server's temporal-tables - and while they do introduce some restrictions (e.g. you can't mark a column as "ignored" for temporal changes, and only system-versioning (not application-versioning) is currently supported) the feature has overall been an absolute lifesaver for allowing us to do data-recovery from user-error on a per-record basis - all from within our application or directly in T-SQL; whereas previously we'd need to get do a full mount of a PITR backup which requires a lot of manual steps and can take at least an hour in most cases - and then hope that we got the exact point-in-time correct.

Even for its use as an auto-auditing system, it's great: we often get customer complaints about us "losing their data" or that we corrupted their records, when in-fact, we have the historical rows and can see that it was one of their own employees (or family-members...) mucking around. Previously we'd have cheerfly accepted the user's complaint and given them a refund or service-credit because it was too much hassle to dig-up the weeks-old HTTP logs or have anxieties about we having any non-transaction-safe OLTP code running causing corruption that we don't know about :S

Re:Implementing system-versioned tables in Postgres by hobs on Wednesday February 07, 2024 @04:29PM (#39294549)
Schema changes basically causing heterogeneous representations of data. If you only add columns forever and never change types its fine. Oh, and being able to specify the time a thing happened is sometimes useful (though you don't want everyone doing that of course...)

Also double checking the docs because its been 5 years since I have reasonably touched SQL Server - no indexes on historical tables so it gets slow fast, Filetable doesn't work* /nvarchar(max) records bloat you hard core.

I find that a log record is much better as a non relational/document type record that is isomorphic to the record so I can schema on read if I need to, and if you want to JSON query that stuff it works fine too.

* but nobody uses it anymore

Re:Implementing system-versioned tables in Postgres by donor20 on Wednesday February 07, 2024 @09:25AM (#39288921)
RDS is 50 cents or less a day for postgresql on a three year term for a small instance.

I use AWS / RDS - I’ve got to believe RDS is spinning money for AWS because of all the parts I want to be reliable this is way up there.

Re:Implementing system-versioned tables in Postgres by deterministic on Friday February 09, 2024 @08:22PM (#39322548)
I am sorry to say this but most developers either don’t have the ability to think for themselves or can’t be bothered.

You might disagree with this statement of course but that is truly my experience (30+ years of working professionally in software development).

Try this: Next time a developer confidently suggests that you should use tech X, ask them that the pros/cons are compared with using tech Y/Z. Ask about performance/failover/latency/team skills required etc. Most developers in my experience completely fail to give an intelligent answer. They are just loudspeakers confidently copying the opinions of somebody else. Usually somebody who benefits financially from developers using tech X.

Re:Implementing system-versioned tables in Postgres by arjunlol on Monday February 12, 2024 @03:33PM (#39350092)
This is actually what we're building @ Bemi https://bemi.io/

We're hoping to make it so that this becomes automatic with Postgres vs moving to specialized databases.

We recently open sourced the core tech that implements system versioned tables https://github.com/BemiHQ/bemi, check it out if interested :)