Repository navigation
Backlog
Labels
Description
Problem
- Nothing shows until the end. Fetch All shows no row and no count until the last row has arrived and every row is built.
- The statement runs twice. Fetch All runs the statement again from the start, so a sort, an aggregate or a hash join costs the server twice.
- A cut result reads as complete. When the read stops early, Fetch All still reports the result as complete. A 10M-row Fetch All on PostgreSQL moves all 10M rows over the wire, keeps 5,000,000, and shows them with no truncation mark and no way to fetch more.
Cause
- The re-run. Fetch All sends
baseQueryagain withrowCap: nil(apple/TablePro/Core/Coordinators/PaginationCoordinator.swift:366-373). Execute Without Limit takes the same uncapped read. - The whole result, then the build.
- On PostgreSQL the read collects every row into
SingleRowRead.rows(apple/Plugins/PostgreSQLDriverPlugin/LibPQPluginConnection.swift:2343-2345,singleRowReadSyncat:2354). - Only then does
TableRows.preparingbuild the rows (PaginationCoordinator.swift:386-393), and they are installed in one step on the main actor (:405-430). - If the shape changed meanwhile, the fallback
rows.replacerebuilds every row on the main actor (:416-423). - The unloaded-value fold re-slices every row first (
:381).
- On PostgreSQL the read collects every row into
- The flag.
singleRowReadSynckeeps at mostPluginRowLimits.emergencyMaxrows by default (LibPQPluginConnection.swift:2357). It reads and drops the rest without decoding (:2352-2353), and reportsisTruncated: read.rowCount > maxRows(:2462).- Fetch All ignores that. It calls
tab.pagination.resetLoadMore()and setstab.display.activeResultSet?.isTruncated = falsewhatever the read reported (PaginationCoordinator.swift:428-429).resetLoadMoreclearshasMoreRowsandbaseQueryForMore(apple/TablePro/Models/Query/QueryTabState.swift:443-448), so Fetch All is no longer offered.
- Unused pieces.
- The plugin ABI already streams (
streamRows), but only export, object copy and compare use it (apple/TablePro/Core/Plugins/StreamingQueryExportDataSource.swift:42,apple/TablePro/Core/ObjectCopy/ObjectCopyRowCopier.swift:109,apple/TablePro/Core/Compare/CompareRowService.swift:274). TableRows.appendPage(apple/TablePro/Models/Query/TableRows.swift:390) has no caller outside tests.
- The plugin ABI already streams (
- Why the cost is paid twice. For a plain SELECT the first capped read stops near the cap, so the repeat is cheap. For a statement whose cost comes before its first row, the server does all of that work again. On PostgreSQL the capped cursor read already fetches the cap and then runs the rest with
MOVE, for write safety (apple/Plugins/PostgreSQLDriverPlugin/LibPQCappedCursorRead.swift).
Overlaps #4464: TOS-F (a capped parameterized PostgreSQL read runs to its end on the wire, and a safe stop needs the server's read-only mode or a savepoint cursor), the editor's capped read that cancels outside a transaction, and the Fetch All prompt's missing test seam. This issue covers what Fetch All and Execute Without Limit do after the prompt.
Change
- Keep the flag. This can ship first, without perf(results): hold every Mac result in the core's columnar store #4521. Fetch All takes truncation from what the read reports, the same way the first run does (
apple/TablePro/Core/Coordinators/QueryExecutionCoordinator+Helpers.swift:337-342). A read that stopped early keepsisTruncatedandhasMoreRows, and the status bar says so. - Stream into the store. Fetch All and Execute Without Limit read through a batch stream into the store from perf(results): hold every Mac result in the core's columnar store #4521. The grid grows with each batch, the status bar shows a live row count, and Stop ends the read at the next batch and keeps the rows already read, marked as partial. The unloaded-value fold moves into the batch build, and nothing rebuilds rows on the main actor.
- Continue, do not re-run, where the engine allows it safely.
- On PostgreSQL, a capped read of a statement the server runs as READ ONLY keeps its cursor (the
LibPQCappedCursorReadplan) instead of moving past the rest. Fetch All then fetches the rest of the same cursor. - The cursor and its transaction end when the read finishes, on Stop, on re-run, on tab close, or before any other statement runs on that session.
- Use the same read-only condition TOS-F in perf(grid): table open, save and query reads left from #4458 #4464 needs.
- An engine that cannot resume a read safely re-runs it, and the prompt says the statement runs again. MySQL is one: a
mysql_use_resultreader left open blocks the connection and tripsnet_write_timeout.
- On PostgreSQL, a capped read of a statement the server runs as READ ONLY keeps its cursor (the
- No cap. Once perf(results): hold every Mac result in the core's columnar store #4521 holds results, no read stops at 5,000,000 rows (D3). The editor row limit stays the user's setting, and Fetch All is the user's choice to pass it.
Measure
- PostgreSQL
trips_1mandtrips_10min a query tab, Fetch All. Record time to the first visible row after confirming, time to the last row, and peak phys_footprint. Target: the first rows within one batch's time, not after the full transfer. - A 30 s aggregate query:
pg_stat_statements.callsgoes from 2 to 1 for Fetch All. - Before perf(results): hold every Mac result in the core's columnar store #4521: a 6M-row Fetch All shows as truncated with Fetch All still offered (test on
performFetchAllwith a stub driver that reportsisTruncated). After perf(results): hold every Mac result in the core's columnar store #4521:trips_10mholds all 10M rows. - Stop halfway through a Fetch All keeps the rows already read, and the connection is idle afterwards.
Part of the performance plan; depends on #4521.
Activity