-
Notifications
You must be signed in to change notification settings - Fork 16k
thomasgauvin: update docs for cache status volatile, stable functions #28536
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
Merged
thomasgauvin
merged 7 commits into
production
from
thomasgauvin-hyperdrive-volatile-stable-functions-cache-clarification
Feb 26, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9f19d13
thomasgauvin: update docs for cache status volatile, stable functions
thomasgauvin b5cc02d
Fix changelog link text, CI passes
ask-bonk[bot] 86539f4
Address 4 PR review comments
ask-bonk[bot] 588ca6e
Move link to "that PostgreSQL categorizes"
ask-bonk[bot] 3bbe77a
Apply suggestions from code review
Oxyjun cec765c
Update src/content/docs/hyperdrive/observability/troubleshooting.mdx
thomasgauvin 4ed515e
Update src/content/docs/hyperdrive/observability/troubleshooting.mdx
thomasgauvin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...ent/changelog/hyperdrive/2026-02-23-hyperdrive-stable-functions-uncacheable.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| title: Hyperdrive no longer caches queries using STABLE PostgreSQL functions | ||
| description: Hyperdrive marks queries containing STABLE PostgreSQL functions as uncacheable, preventing stale cached results. | ||
| products: | ||
| - hyperdrive | ||
| date: 2026-02-23 | ||
| --- | ||
|
|
||
| Hyperdrive now treats queries containing PostgreSQL `STABLE` functions as uncacheable, in addition to `VOLATILE` functions. | ||
|
|
||
| Previously, only functions [that PostgreSQL categorizes](https://www.postgresql.org/docs/current/xfunc-volatility.html) as `VOLATILE` (for example, `RANDOM()`, `LASTVAL()`) were detected as uncacheable. `STABLE` functions (for example, `NOW()`, `CURRENT_TIMESTAMP`, `CURRENT_DATE`) were incorrectly allowed to be cached. | ||
|
|
||
| Because `STABLE` functions can return different results across different SQL statements within the same transaction, caching their results could serve stale or incorrect data. This change aligns Hyperdrive's caching behavior with PostgreSQL's function volatility semantics. | ||
|
|
||
| If your queries use `STABLE` functions, and you were relying on them being cached, move the function call to your application code and pass the result as a query parameter. For example, instead of `WHERE created_at > NOW()`, compute the timestamp in your Worker and pass it as `WHERE created_at > $1`. | ||
|
|
||
| Hyperdrive uses text-based pattern matching to detect uncacheable functions. References to function names like `NOW()` in SQL comments also cause the query to be marked as uncacheable. | ||
|
|
||
| For more information, refer to [Query caching](/hyperdrive/concepts/query-caching/) and [Troubleshoot and debug](/hyperdrive/observability/troubleshooting/). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.