@Matt any idea from those explain statements / queries what is causing the write?
@Matt any idea from those explain statements / queries what is causing the write?


/site directory where I keep my frontend and is what is built when I run npm run build to the /dist directory./functions directory which is of course where I am storing my backend API./sql directory to house the SQL and migrations?count(distinct "id") I get rows_written in meta?

849f0f66-2128-44b7-ab25-8776dacfb571 (in case it's needed)

SQL execute error: database or disk is full errors on our D1 db, we are using 104.86 MB and are on a paid plan. (DB ID is 2211f2a0-4f44-4b32-b1a6-01b4d3f09f0a if it helps)npx wrangler d1 info <dbname> on that DB?[ERROR] Internal error in D1 storage caused object to be reset. [code: 7500]pragma foreign_keys=0 does not work in D1’s automatic transactions. I found some advice in this discord to use pragma defer_foreign_keys=1 which still didn’t fix my issue, just got a mysterious error message. Finally I stumbled on this hint: https://sqlite.org/forum/forumpost/825039816c3f0097 If you also reset pragma defer_foreign_keys=0 at the end of the script it will completely skip the foreign key checking. Feels a bit risky since even pragma foreign_key_check is disabled in D1 and I don’t have a good way to confirm my data is still valid. But I’m glad I could at least apply my migration.--local flag have a more deterministic name? Right now my db file is located at .wrangler/state/v3/d1/miniflare-D1DatabaseObject/e7352547963de7050bd7d94658afc4fe78b61811b7815da12d90be8e863abf4d.sqlite, but I'd prefer something more memorable. I'm also not sure if someone else who runs the setup locally would get the same file name.--persist-local=db.sqlite, but that seems to change the top level folder only, so then the DB file is at db.sqlite/v3/d1/miniflare-D1DatabaseObject/e7352547963de7050bd7d94658afc4fe78b61811b7815da12d90be8e863abf4d.sqlite


for (const { question, answer } of objectsData) {
// Check if the row with the same question and answer already exists
const existingRow = await env.faq.prepare().run(question, answer);
if (!existingRow) {
// If the row doesn't exist, insert it into the table
await env.faq.prepare().run(question, answer);
}
}
/sitenpm run build/dist/functions/sqlcount(distinct "id"){
"collectionItems": {
"success": true,
"meta": {
"served_by": "v3-prod",
"duration": 0.6292,
"changes": 0,
"last_row_id": 0,
"changed_db": false,
"size_after": 3862528,
"rows_read": 1014,
"rows_written": 342
},
"results": [
{
"count(distinct \"id\")": 342
}
]
}
}849f0f66-2128-44b7-ab25-8776dacfb571SQL execute error: database or disk is full2211f2a0-4f44-4b32-b1a6-01b4d3f09f0anpx wrangler d1 info <dbname>➜ ~ npx wrangler d1 info odometer ✘ 1
┌────────────┬──────────────────────────────────────┐
│ │ 2211f2a0-4f44-4b32-b1a6-01b4d3f09f0a │
├────────────┼──────────────────────────────────────┤
│ name │ odometer │
├────────────┼──────────────────────────────────────┤
│ created_at │ 2023-06-08T10:24:40.711Z │
├────────────┼──────────────────────────────────────┤
│ version │ alpha │
├────────────┼──────────────────────────────────────┤
│ num_tables │ 2 │
├────────────┼──────────────────────────────────────┤
│ file_size │ 105 MB[ERROR] Internal error in D1 storage caused object to be reset. [code: 7500]pragma foreign_keys=0pragma defer_foreign_keys=1pragma defer_foreign_keys=0pragma foreign_key_check--local.wrangler/state/v3/d1/miniflare-D1DatabaseObject/e7352547963de7050bd7d94658afc4fe78b61811b7815da12d90be8e863abf4d.sqlite--persist-local=db.sqlitedb.sqlite/v3/d1/miniflare-D1DatabaseObject/e7352547963de7050bd7d94658afc4fe78b61811b7815da12d90be8e863abf4d.sqlite for (const { question, answer } of objectsData) {
// Check if the row with the same question and answer already exists
const existingRow = await env.faq.prepare().run(question, answer);
if (!existingRow) {
// If the row doesn't exist, insert it into the table
await env.faq.prepare().run(question, answer);
}
}