-
Notifications
You must be signed in to change notification settings - Fork 283
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
Allow partial pipelining within a transaction #951
Comments
Alternatively, maybe there could be a specific |
I think your example is great, and ought to work :) Also for doing it in the middle of other queries this should be supported: await sql.begin(async sql => {
const [movie] = await sql`
SELECT * FROM Movie
WHERE name = 'Star Wars'
`
await Promise.all([
sql`
INSERT INTO MovieActor
-- some statement using ${movie.id}
`,
sql`
INSERT INTO MovieReleases
-- some statement using ${movie.id}
`,
// etc
])
await sql` ... something else `
}) I might have some time to toy with this soon, but if you want to take a stab at it, feel free :) |
Until then, are you sure your use case can't work with CTE's ? |
I think CTEs can work in most situations, but it would be nice to have the option to pipeline statements. |
Another place where partial pipelining would be great is when using temporary tables. For example: await sql.pipeline(sql => [
sql`
CREATE TEMP TABLE ActorsInYear
ON COMMIT DROP AS
SELECT Actor.*
FROM Actor
JOIN MovieActor USING (ActorId)
JOIN Movie USING (MovieId)
WHERE Movie.Year = ${year}
`,
sql`
CREATE INDEX ON ActorsInYear(ActorId)
`,
sql`
ANALYZE ActorsInYear
`
]);
// Do something with ActorsInYear |
Allow pipelining the some requests in a transaction without requiring that all the requests are pipelined. This would allow selecting to get the id of a row, then issuing multiple statements based on the id of the row in a pipelined fashion.
For example:
The text was updated successfully, but these errors were encountered: