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

feat: Query level SQL caching #977

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

feat: Query level SQL caching #977

wants to merge 5 commits into from

Conversation

BobdenOs
Copy link
Contributor

@BobdenOs BobdenOs commented Jan 14, 2025

By attaching a SQL cache to executed queries it becomes possible to skip a lot of processing especially for more complex queries. Therefor this PR introduces the initial setup for creating and leveraging re usable CQN queries SQL caches.

Currently in most writing queries resolveView is used to be able to write into entities that cannot be written into directly on the database. The big drawback of the resolveView usage is that it does not just modify the query, but also modifies the attached data. Therefor this PR also removes the early resolveView and leverages the getTransitions and getDBTable functions instead to bake the data transformation directly into the SQL statements. This mostly comes down to defining different column names in the SQL from the JSON properties send to the database service.

INSERT INTO Books (ID, title, descr) SELECT value->>'key', value->>'book_name', value->>'description' from json_each(?)

Allowing the caching mechanism to simply re-use the SQL produced before and serializing the new entries. Without having to call resolveView on each call even when cached.

There is a clear problem by having the caching mechanism be added on the lowest level. Is that currently many applications will be relying on directly modifying CQN without calling cds.ql.clone or q.clone which is now required to receive the expected results. As clone will invalidate any SQL cache on the proto query.

Additionally the remove of resolveView allows for proper adoption of Iterator and Readable insert sources. As implemented by: #844

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.

1 participant