Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support binary format #506

Open
bitonic opened this issue May 12, 2021 · 6 comments
Open

Support binary format #506

bitonic opened this issue May 12, 2021 · 6 comments

Comments

@bitonic
Copy link

bitonic commented May 12, 2021

libpq supports a binary interchange format -- see https://www.stackage.org/haddock/lts-17.11/postgresql-libpq-0.9.4.3/Database-PostgreSQL-LibPQ.html#v:execParams .

We recently ran into some performance issues, and I suspect that avoiding to escape the results of queries would greatly help. However I think opaleye and even postgresql-simple do not support the binary format -- so I didn't go very far.

@tomjaguarpaw
Copy link
Owner

Interesting. I am not familiar with this. Is it just the results of the queries you want to be in binary format, or also the query itself. From the API you linked it looks like only the query parameters can be in binary format, not the query itself. Is that right?

@tomjaguarpaw
Copy link
Owner

If you can give me an example of how to use the LibPQ API then perhaps I can tell you how to get Opaleye to use it. However, at the moment Opaleye leans very heavily on the parsers in postgresql-simple. It's possible that we would have to rewrite a lot of parsing code.

@bitonic
Copy link
Author

bitonic commented May 12, 2021

My understanding is that it is possible to get results in binary format, see for example https://www.postgresql.org/docs/9.6/libpq-example.html#LIBPQ-EXAMPLE-3 .

However, I have not investigated how to execute a similar query in Haskell yet. I'll update this issue if I get to it, although the performance problems I mentioned are currently not so critical, and so it probably won't happen very soon.

@tomjaguarpaw
Copy link
Owner

OK, it's good to have this issue here as a reminder that it would be a useful thing to implement. I don't currently have the time to drive this forward myself, but if you discover how to fit all the pieces together I can help you plug it into Opaleye.

(Having said that, it's possible that this should go into postgresql-simple instead, in which case it would fit into Opaleye naturally.)

@ParetoOptimalDev
Copy link

Would it be possible to re-use parts from hasql for this?

It uses the binary interface.

@tomjaguarpaw
Copy link
Owner

Theoretically we could just add a hasql backend. That's what rel8 does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants