/cdn-cgi/trace on your worker's hostname, look for colo=<airportCode>. If you have Smart Placement enabled, then check the cf-placement response header, end of that is airport code.npx wrangler d1 info <dbName>, If you're not sure. you'll get a region returned like ENAM (East North America), or APAC (Asia Pacific)duration You can also do performance.now before/after query to measure end to end latency of each query and shove it into a response header or console.log itnpx wrangler d1 insights <db> can be helpful for debugging slow queries as well
D1PreparedStatement has a statement property, but TS doesn't know about itpreparedStatement.statement is not meant to be used by client Worker code (i.e. you). You have access to the statement since you are the one providing it to the prepare() method, so use that instead.prepare() and optionally bind(), only call these methods: https://developers.cloudflare.com/d1/worker-api/prepared-statements/When using Durable Objects, it's important to remember that they are intended to scale out, not up. A single object is inherently limited in throughput since it runs on a single thread of a single machine. To handle more traffic, you create more objects. This is easiest when different objects can handle different logical units of state (like different documents, different users, or different "shards" of a database), where each unit of state has low enough traffic to be handled by a single object.
wrangler d1 command, is there any way to change the output mode to be insert? --json flag value
/cdn-cgi/tracecolo=<airportCode>npx wrangler d1 info <dbName>durationnpx wrangler d1 insights <db>const [ widget ] = await db.select().from(schema.widgets).where( eq(schema.widgets.id, widget_id) ).limit(1)D1PreparedStatementstatementTSpreparedStatement.statementprepare()prepare()bind()wrangler d1insert--jsonwrangler d1 backup create cyguro-db-dev
✘ [ERROR] A request to the Cloudflare API (/accounts/2d2da569ea5c41d87eba7d610279d290/d1/database/c25c6f21-3669-4672-9eaf-58242589258c/backup) failed.
The request is malformed: Only alpha D1 databases support backups. Production databases support
time-travel: c25c6f21-3669-4672-9eaf-58242589258c (v3) [code: 7400]// This code works
const ps = env.DB.prepare(pragmaStmts[key]);
const data = await ps.all();
jsonData.push({ statement: ps.statement, [key]: data.results });
//ts complains:
`Property 'statement' does not exist on type 'D1PreparedStatement'.ts(2339)`# npm ls
@cloudflare/workers-types@4.20241230.0