Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/poor-points-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@opennextjs/cloudflare": patch
---

perf: add an index on the tag column in D1 tag cache

It only applies to newly created tables
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class D1NextModeTagCache implements NextModeTagCache {
await db.batch(
tags.map((tag) =>
db
.prepare(`INSERT INTO revalidations (tag, revalidatedAt) VALUES (?, ?)`)
.prepare(`INSERT OR REPLACE INTO revalidations (tag, revalidatedAt) VALUES (?, ?)`)
.bind(this.getCacheKey(tag), Date.now())
)
);
Expand Down
2 changes: 1 addition & 1 deletion packages/cloudflare/src/cli/commands/populate-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function populateD1TagCache(
[
"d1 execute",
D1_TAG_BINDING_NAME,
`--command "CREATE TABLE IF NOT EXISTS revalidations (tag TEXT NOT NULL, revalidatedAt INTEGER NOT NULL, UNIQUE(tag) ON CONFLICT REPLACE);"`,
`--command "CREATE TABLE IF NOT EXISTS revalidations (tag TEXT PRIMARY KEY, revalidatedAt INTEGER);"`,
`--preview ${populateCacheOptions.shouldUsePreviewId}`,
],
{
Expand Down
Loading