無上限、可溢寫到磁碟的結果

功能性的

以背壓與磁碟溢寫串流大型結果,不讓一個超大回應吃光整台機器的資源。

超大的結果集不該變成超大的記憶體問題。資料列以串流方式穿過 背壓通道 而且超過某個門檻後, 溢寫到磁碟, so the grid pages from an on-disk store whether a query returns 50 rows or 50 million.

資料列經過的路徑

  1. The driver batches. Rows come off the wire in batches with a flush timer, so a slow query still shows you what it has rather than nothing.
  2. The channel pushes back. The queue between driver and UI is bounded. If the grid cannot keep up, the driver waits, which is what stops a fast server from filling memory faster than the app can drain it.
  3. Past the threshold, it spills. Beyond 50,000 rows (或一個 64 MiB per-set memory budget, whichever comes first) the set is written to a typed binary spill file with its own row-offset index, and the in-memory copy is released.
  4. The grid pages. A spill-backed set keeps a window of rows resident around your viewport and re-centres it, on a background task, as you scroll. The index is paged too, so the cost does not grow with the size of the set.

You keep working while this happens. The grid paints as rows arrive rather than waiting for completion, the live row count updates as it goes, and repaints are coalesced so streaming a million rows does not spend its time redrawing.

Pivot and chart every row

這 樞紐分析 和 圖表 tabs work on spill-backed sets too. Each time you change the layout they read the whole spill file on a background task, showing Pivoting… 或 Charting… with a percentage, and memory stays flat however many rows there are. Drill-through works as well: double-click a pivot cell, or click a bar, slice, or histogram bin, and SQLly collects exactly the rows behind it into a temporary file of their own and shows them on the Grid tab under a banner. 清除 brings back every row.

Honest about the trade

溢寫到磁碟的代價。 以溢寫支撐的資料集存放在磁碟而非記憶體中,因此 sort, filter, and diff are disabled for it. Those need the whole set at once, and quietly sorting the visible window would be a lie. Export is fine: it pages the complete set straight from the file. Pivot and chart are fine too, as above, though on a very large set each change takes a moment longer while the file is read.

Spill files are temporary and owned by the run that made them. Closing the tab or starting a new query deletes them, along with any drill-through files made from them, and a superseded query cleans up after itself even if its results arrive late.

在瀏覽器中

這 瀏覽器版本 (the live preview, and SQLly Embedded pages) spills too. A browser tab has no disk to write to, so past the same threshold the rows go to the browser's Origin Private File System, private storage the browser keeps for the site. A small background worker owns the files, because only a worker can read and write them synchronously; the app sends it rows in the same spill format the desktop uses and asks it for the rows on screen as you scroll, so the tab's memory stays flat while a multi-million-row result scrolls like a short one.

  • What works: scrolling, View Row as Form, copy and export (the first 100,000 rows, like an in-memory export on the desktop), Top Values and profiling, Pivot and Chart over every row, and pivot drill-through.
  • Pivot and chart read the stored rows back the first time you open them on a result. The rows are held in the browser's memory, outside the app's own, until the result is replaced.
  • Cleanup: the files go when the result is replaced or closed. A tab that closes before it can tidy up leaves them behind, and the next SQLly page in that browser removes them on startup; files another open tab is still using are left alone.
  • When it can't: a browser without OPFS, a private window that refuses it, or one with less than about 64 MB of storage free keeps the whole result in memory, as before, and says so in Messages. If storage fills up partway through, SQLly keeps the rows it managed to store and tells you how many.

調整它

兩個旋鈕都位於 設定 › 效能 › 查詢結果最佳化:資料列門檻與每組記憶體預算(1 MiB 至 2 GiB)。記憶體充裕、又想排序更大資料集時可以調高;機器不大就調低。