HomeVideos

Your AI Agents Don't Have A Postgres Problem (They Have A Setup Problem)

Now Playing

Your AI Agents Don't Have A Postgres Problem (They Have A Setup Problem)

Transcript

213 segments

0:00

Let's think about this. A Postgres

0:01

couldn't handle AI agent. Somebody

0:04

forgot to tell Open AI 800 million

0:06

people use ChatGPT right now and the

0:08

thing storing all their data is one

0:11

Postgres database. One main database

0:14

plus around 50 copies that handle the

0:16

lookups serving millions of requests a

0:18

second. So, when you see that line on

0:20

the internet going around the one that

0:22

says Postgres was never built for AI

0:24

agents, I want to slow you down because

0:26

I think it's half true. It's my opinion

0:28

the half they skip is the half that

0:31

costs you money. Okay, so quick ground

0:33

level version for you. So, since most of

0:35

you probably don't work in databases

0:36

day-to-day, databases the back office of

0:39

your software. It's where your orders

0:41

and customers live sorted so you can

0:43

pull them off very fast. And Postgres is

0:45

one specific database and it's the

0:47

popular ones out there. It's free and

0:49

open source which means anyone can use

0:51

it and look under the hood. And it's

0:53

been around for decades. Banks run on it

0:56

and so does Open AI. Now, an AI agent in

0:59

plain English is software that does

1:00

multi-step work on its own as you

1:02

already know. It doesn't wait for you to

1:04

click every button. So, when people say

1:06

agents use a database, they mean the

1:09

agent keeps saving and pulling back

1:10

information the whole time it works. And

1:12

as you probably know that every few

1:14

months, I mean every few weeks from now,

1:16

few days, the whole entire internet

1:18

decides one tool is dead and a shiny new

1:20

one comes out and it has to replace it

1:22

or whatever, right? Right now it's

1:24

Postgres. And the people saying it the

1:26

loudest tend to be the ones selling the

1:28

replacement, right? So, the claim sounds

1:31

very technical. Here, I'm going to

1:33

explain to you. So, it feels your old

1:35

database was built for a humans. Agents

1:37

are different. So, you need a database

1:38

built for agents. My take on this is

1:41

what the logic skips a step. [music] Um

1:43

my personal opinion and the skipped step

1:45

is where they can get you. Honestly, the

1:48

one real thing that breaks is smaller

1:51

than they make it sound. Every time

1:53

software talks to Postgres in the back

1:55

end, it opens a connection and Postgres

1:58

hands that connection its own dedicated

2:00

worker. We can think of it like a

2:02

assigning a personal clerk to every

2:04

single visitor who walks into your back

2:06

office. So, there's one normal app opens

2:08

a handful of connections and holds onto

2:11

them. A few clerks, no problem. Now,

2:13

point A's swarm of agents said it, they

2:15

open connections fast in parallel, then

2:18

drop them over and over and over again.

2:20

The checks, the clerks pile up, they

2:23

crowd the back office, and the whole

2:25

thing slows down. So, what that

2:27

basically means is the filing system

2:29

isn't broken, it's the office that's

2:31

sitting in it is now just crammed with

2:34

clerks it was never stepped for. So, you

2:36

put a connection puller in front of

2:38

Postgres, and remember that personal

2:40

clerk for every visitor? A puller turns

2:42

that into a shared front desk. A few

2:44

clerks now handle everyone in turn. So,

2:47

5,000 agents end up sharing maybe 50

2:50

workers. I hope that makes sense. And

2:52

that is not an exotic open AI once one

2:55

of these in front of their database, and

2:57

it cut their connect time from 50

2:59

milliseconds to 5 milliseconds. And

3:00

Andres Freund, one of their engineers

3:02

who actually builds Postgres, measured

3:05

what a single connection cost. He found

3:07

it is tiny, under like 2 MB, and said

3:09

memory wasn't even the limit that

3:11

actually matters here. That scary story,

3:14

the one where Postgres falls over the

3:16

second agents show up, is mostly a setup

3:19

problem wearing a costume. And now, I'm

3:22

not going to pretend the new database

3:23

companies invented nothing here. There's

3:26

one trick here that didn't exist in

3:28

plain Postgres, and I think it's worth

3:30

understanding. It's called branching.

3:33

Normally, your data and the computer

3:35

running it are glued together. So,

3:37

making a full copy is slow, and it can

3:40

get very expensive. [music] The newer

3:42

platforms, they um them, pull those two

3:45

apart, separate it, and that lets them

3:47

hand an agent a private copy of your

3:49

whole database in under half a second.

3:51

They use it, then throw it away. So, for

3:54

agents, that's real. If you want every

3:56

agent to run its own experiment in a

3:58

sandbox and throw it away after

4:00

branching, I think it can give you that

4:03

really at a cheap cost. So, my take on

4:05

this is I think this is very tangible

4:07

actual product here, and it's a good

4:09

one, my personal opinion. So, why don't

4:11

we follow the money? Because that's

4:13

where it gets obvious. In 2025, more

4:15

than 1.25 billion dollars moved to buy

4:18

Postgres companies. Databricks hit

4:21

around a billion dollar for Neon. We

4:23

probably use Neon a lot in our real

4:25

life. And Snowflake paid around 250

4:28

million dollars for Crunchbase. I want

4:29

you to sit with that for a second

4:31

because the Postgres engine is free and

4:33

open source, and anyone just can

4:35

download it to use it today. Okay, then,

4:38

what did they actually pay for? A

4:39

billion and 2.5 billion dollars? They

4:42

paid for the thing wrapped around it.

4:43

The paper use billing and the instant

4:46

copies, that's the part with the price

4:48

tag. An agent needed is the label that

4:51

just staple on it, right? While you keep

4:53

looking at the engine. Vector search, by

4:55

the way, is the bit of the tag that lets

4:57

a database find things by meaning, which

4:59

is what AI needs. A Postgres writer who

5:02

goes by Vaughn says it's best here. "And

5:05

bolting on vector search now gets the

5:07

product stamped AI native." [music] The

5:09

same movie we watched with cloud native.

5:11

The label changes, the engine underneath

5:13

does not. So, I think this can flips in

5:16

two different spots. And I want you to

5:17

know them before you go quote me on, you

5:20

know, anything. So, if your agents

5:22

really spin off and throw away thousands

5:24

of databases at machine speed, I think

5:26

plain Postgres on one always-on computer

5:29

can hurt you. So, that's the case the

5:32

serverless platforms are built for. The

5:34

pay-only when you use it kind, like. And

5:36

there, they are [music] in it. It also

5:38

flips the other way. If your software

5:39

runs steadily all day, a plain always-on

5:42

computer is cheaper. So, the pay-per-use

5:44

option also has to wake up when an agent

5:47

calls. And that wake up has a short

5:49

delay. Once you're using it more than

5:51

about a third of the day, the modern

5:53

option starts costing you much, much

5:56

more. So, I think not copying the trend

5:59

blindly will help you immensely. I mean,

6:02

obviously you do you do your research

6:03

though. Yeah, do your due diligence to

6:05

make sure what I'm saying is accurate,

6:07

you know. So, what you can do with it is

6:09

put a connection puller in front of

6:10

Postgres if you think you need one. The

6:13

common free one is called PG Monitor.

6:15

This kills most of the agents are

6:17

monitoring my database paying on day

6:19

one. So, and also don't buy anything

6:21

labeled agent native [music] until it

6:24

names one real difference under the

6:25

hood. Instant copies and paper use

6:27

count. Vector search does not. And you

6:29

can figure out how much of the day your

6:31

software is busy before you go pay for

6:34

use. Busy in bursts, paper use wins.

6:37

Busy all day, and always on computer is

6:39

cheaper. If you're building agents, I

6:41

think having them retrying on their own

6:44

when they bump into each other. When two

6:47

agents grab the same record, Postgres

6:49

doesn't smooth it over. It just throws

6:52

an error. So, this is where I land. This

6:53

is all my personal opinion. Don't take

6:55

this blindly. [music]

6:56

Postgres wasn't built for agents the

6:58

same way it wasn't built for the web or

7:01

for like smartphones. It absorbed both

7:04

without changing its core, the engine.

7:06

And it's absorbing agents the same way

7:08

right now. The work is real, yeah. I

7:11

admit it. I admit that. It's just

7:12

happening in the layer wrapped around

7:15

the engine. I hope that makes sense. So,

7:17

before you switch anything, why don't

7:19

you figure out whether you got a

7:20

Postgres problem or just a setup

7:22

problem? And most of you, I swear to

7:24

God, you have a setup problem. So, do it

7:26

right the first time. Anyway, that's my

7:28

personal read on this one. And if you

7:30

want to see more of this, me talking

7:32

about these kind of stuff, why don't you

7:33

comment down below me

7:35

>> [music]

7:35

>> covering whatever you want because that

7:37

is how our channel runs. You ask, I

7:39

build, we all learn. See you in the next

7:40

video.

Interactive Summary

The video discusses the common claim that Postgres is unsuitable for AI agents, arguing that this is largely a misconception driven by marketing. The narrator explains that most performance issues attributed to Postgres are actually configuration problems, specifically related to connection handling, which can be mitigated using connection poolers. While acknowledging that newer database platforms offer useful features like instant database branching and pay-per-use models, the core Postgres engine remains highly capable. The video advises viewers to evaluate their specific workloads—distinguishing between bursty agent tasks and steady, always-on processes—to determine the most cost-effective architecture before switching away from Postgres.

Suggested questions

4 ready-made prompts