cloudflare / cloudflare/developer-platform

🐛 BUG: Very wrong metrics reported for row reads after a `execute --file` (3 order of magnitude bigger than expected).

オープン
#44 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
product:d1
主要言語
言語のデータがありません
スター
1
フォーク
0
PR マージ指標
30日以内にマージされた PR はありません

説明

### Which Cloudflare product(s) does this pertain to?

D1

### What version(s) of the tool(s) are you using?

3.67.1

### What version of Node are you using?

18.19.0

### What operating system and version are you using?

Linux Manjaro (arch)

### Describe the Bug

### Observed behavior
After an execution of `DELETE` statement from a sql file, the metric returned in the terminal (the same number is in the web dashboard) for rows read was astronomically bigger than it should be:
```sh
npx wrangler d1 execute prods --file $rm_rows_sql --remote
#returns
rows read: 70344030 (web dash display 70.72M)
```
`prods` db has close to 12K rows.
the executed slq file is something like this:
```sql
DELETE FROM products WHERE tid IN (5, 22, 34, 38, 41, 50, 57, 64, 90, 98,..)
```
where the list of values is about 1k integers and `tid` is indexed. The statement was correctly applied and it took only a few seconds.

### Expected behavior
A correct number of rows read, something like:

```sh
sqlite> .read del_not_shared.sql
QUERY PLAN (cycles=113272102 [100%])
`--SEARCH products USING INTEGER PRIMARY KEY (rowid=?) (cycles=26065003 [23%] loops=1 rows=1272)
```

### Steps to reproduce
Please provide the following:
- A minimal working subset of your worker code
- A minimal working subset of your `wrangler.toml`
- Commands used to start your local dev server, including custom env and cli args
- Steps to be performed in the browser, curl commands, or a test we can run that reliably fails (at least a percent of the time)

A git repo we can clone and run a test suite on, or which has a README with step-by-step instructions, is even better. In this case, please use the field below to provide a link to the minimal repro.

### Please provide a link to a minimal reproduction

_No response_

### Please provide any relevant error logs

_No response_

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

報告されている `npx wrangler d1 execute ... --file ... --remote` コマンドと DELETE SQL ファイルから始め、ターミナルに表示される読み取り行数のメトリクスを、期待される SQLite のクエリプランの結果と比較します。コマンドが、Issue に記載された期待される動作と一致する、インデックス付き DELETE の妥当な読み取り行数を報告すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
node.js, sql, sqlite
領域
cli, databases
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。