-
Notifications
You must be signed in to change notification settings - Fork 301
Make PostgreSQL selectSource stream results.
#726
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
Conversation
|
Ran into some test failures due to SQL error(s). It appears mutations (INSERT) are getting prefixed with Here's a partial snippet of the database log: |
|
I don't think this is something that is sensible/safe to do unconditionally. Possibly it should be associated with a function that has a type constraining itself to database read actions using the read/write roles. I've been doing related'ish work in Esqueleto: https://github.com/bitemyapp/esqueleto/tree/bitemyapp/validate-read-write-roles I'm also interested in this because I'd like to see streaming sorted out for the next time I need it. |
parsonsmatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran into some test failures due to SQL error(s). It appears mutations (INSERT) are getting prefixed with DECLARE temp1 NO SCROLL CURSOR FOR even though nothing to do with execute has been touched. Any thoughts from Postgres folks?
Yeah - that is an expected behavior of fold. I think that swapping for foldWithOption might fix this issue.
I think I agree with @bitemyapp that this isn't the right place to implement this functionality. It isn't unconditionally faster (the docs on fold say that smaller queries/results will be faster with query), and it is (should be?) limited to ReadOnly queries. I'd be 100% happy to include an addition to the API that gives this functionality, and I would like to see selectSource be made more extensible so that it can take advantage of this.
Since postgres-simple's `fold` + `FromField` instance can handle nearly all the work, libpq dependency has now been fully removed.
`fold` demands we strictly consume each row to avoid space leaks: https://www.stackage.org/haddock/lts-14.19/postgresql-simple-0.6.2/Database-PostgreSQL-Simple.html#v:fold
a298d81 to
7e39b02
Compare
|
@parsonsmatt tried to use options = PG.FoldOptions PG.Automatic $ PG.TransactionMode PG.DefaultIsolationLevel PG.ReadOnly
openS = PG. foldWithOptions options conn query (map P vals) CL.sourceNull processRowAs noted before, looks like |
|
Closing stale PR |
Address #657 for
persistent-postgres.With this, persistent effectively will support streaming results when using
selectSourcefor all* sql backends.*MySQL streaming is available in persistent-mysql-haskell backend.