nbenesch•

The postgres crate is one of my favorite crates in the Rust ecosystem. sfackler has been steadily building a complete and rock-solid libpq replacement in Rust... and it feels like hardly anyone has noticed.

New in this release is:

47
binkarus•

Ah the organizational changes are something I wanted a lot time ago when I was first starting with Rust. I really appreciate the separation of concerns.

3
[deleted]•

[deleted]

1
chollya•

Looks like the API has non-documented incompatibilities to 0.15?

9
nbenesch•

They are documented! Take a look at the changelog: https://github.com/sfackler/rust-postgres/blob/master/postgres/CHANGELOG.md

17
ErichDonGubleradhesion · not-yet-awesome-rust•

I mean, 0.17 means "not Semver-compatible" with 0.15, but yeah, they should be documented.

7
musicmatzeimag · filters · toml-query · kairos•

You think so?

Sometimes it is just too much to do for a small community of developers. I'd say getting the release out of the door is more important than documenting breaking change, especially in 0.y versions...

Edit: to be clear: when moving from 1.y to 2.y, I'd expect a list of breaking changes,... But I'm not so sure whether this I would expect this in zero-something versions...

5
ErichDonGubleradhesion · not-yet-awesome-rust•

To be fair, it depends on the developers' expectations of usage. Experimental library you have high hopes for but only so much time? Just push. Get that satisfaction and keep your open source life sustainable. I'd far prefer that to somebody burning out because they feel bogged down. Avoiding getting bogged down with important (but necessary) details is what Rust was freaking made for, so I understand if somebody just wants to ship their little fun library and feel good about having something to show.

But if the developer is serious about people using their stuff, I think that documenting breaking changes is a necessity for demonstrating your sincerity in helping others use your library, like all other documentation. In my Rust-shaped head, I would think not documenting breaking changes for post-1.0 versions (as you state) would be a joke.

12
kostaw•

Just a quick shout out how awesome tokio-postgres is. Both the performance as well as ease of use of postgresql pipelining combined with Rust futures is unmatched in any other language I’m aware of. This library made Rust THE language to use at work for efficiently dealing with our Postgres dbs.

So a very big thank you to tokio-postgres!

8
ProgrammurrOP•

Can you elaborate on your setup for pipelining? I haven't used Tokio-postgres but will be porting to it soon.

2
sfacklerrust · openssl · postgres•

The crate docs cover it a bit, but all you need to do on the Rust side to take advantage of pipelining is to join!() futures rather than .awaiting on them sequentially: https://docs.rs/tokio-postgres/0.5.1/tokio_postgres/#pipelining

6
robinst•

I was looking at the sequential/pipelined table on mobile (narrow screen) and it's not readable because the lines are wrapped. Is it possible to format it another way to make it work on mobile?

1
ProgrammurrOP•

Oh, they have to be independent calls. Makes sense. Thanks!

1
kostaw•

It’s actually extremely simple. E.g. I have a Stream of Input messages, map() each message to a postgres_client.query() this resulting in a stream of futures (each future is the result of one db operation, for this use case its typically INSERT ON CONFLICT but it works for any query as well).

Now that would only yield one dB operation at a time. That’s why I call stream.buffered(N) which transforms it into N concurrent db operations. The right value of N depends on the latency to the db. If you choose it too low, you leave performance on the table. But the cool thing is: if you set it too high, it only results in a bit of client-side future scheduling and memory overhead, without impact on the Postgres server side.

For additional performance split your stream into M connections.

This results in Postgres have excellent query performance with minimal cpu load. Iirc in our test setup, we had 8 connections from 1 client process with 5k to 10k queries per second each, resulting in a server side flat load average of 2 to 3. I’m not sure but this might even outperform COPY, because you parallelize trivially. (But I haven’t measured because COPY does not work for us)

We tried to replicate this with go and python but the concepts that make this possible don’t exist as far as I can tell. This is a huge rust advantage and in my book.

3
ProgrammurrOP•

Have you checked out deadpool for Tokio-postgres? It was designed for optimum performance and so may give you some boost .

1
kostaw•

No, but I’ll take a look

1
kyusan•

You have to try Ecto from Elixir, it's so good <3

1
ripread•

Where does Diesel stand on all this? Is this a competitor to Diesel? Or will dial use this as a backend?

5
Kamek_pf•

IIRC Diesel binds to libpq. Diesel is an ORM / query builder, it has its own DSL and introspections capabilities.

It's higher level than rust-postgres, so I wouldn't say they are competing directly.

5
dochtmanAskama · Quinn · imap-proto · tokio-imap•

Some time more than a year ago I heard that Diesel wanted to implement their own postgres protocol crate at some point but didn't like the existing work much.

1
rustological•

Is there some more documentation/example code on how to use it? If you already know what tokio is and this async stuff it is probably easy, if you don't it is still a bit mysterious whether something is sync/async, multiple parallel requests are multiplexed on one connection or not, etc. At least I'm still confused.

2
g1rp•

Thanks sfackler for the release, I've been using rust-postgres for a while now.

1
ufo_catcher•

Hi u/sfackler thanks for this, was very easy to get started. What is your intended use for setting up connection pooling with tokio-postgres, is it meant to work with the r2d2 crate?

1
ProgrammurrOP•

Check out deadpool

3