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

merge "insert" and then "select" to a single "insert … returning *" statement #2021

Closed

Conversation

georghas
Copy link
Contributor

@georghas georghas commented Sep 23, 2024

For insertion, AbstractPersistenceManager first inserts data with "INSERT INTO … RETURNING table.ID;", returns the generated
<ID> and then queries the same row using <ID> with "SELECT * FROM table WHERE table.ID = <ID>;".

This requests merges these two operations into one single operation: "INSERT INTO … RETURNING table.*;" Hereby data is inserted, altered by rules or before-triggers (not after-triggers!), should there be any, and then immediately returned. It eliminates the need for another SELECT statement.

(Background: For the default implementation of FROST, this is not noticeable. However when trying to extend the database with TimescaleDB, this small detail speeds up writes significantly.)

@hylkevds
Copy link
Member

Excellent idea! Thanks for the PR.

@hylkevds
Copy link
Member

I fixed the problem that some EntityTypes (Datastreams) use projections in their select list, which were not in the returning list, causing all tests to fail: da0fc6a.

@hylkevds
Copy link
Member

I've merged the PR manually, so we can close this. Thanks again!

@hylkevds hylkevds closed this Sep 24, 2024
@georghas
Copy link
Contributor Author

Awesome. Thank you!

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

Successfully merging this pull request may close these issues.

2 participants