Skip to content

Fifty thousand rows in under a second.

How we made databases open four times faster without a rewrite: a smaller first paint, a smarter query plan and one very boring cache.

HEdited by HanaOct 22, 20269 min read

On October 21 we shipped faster databases: tables with 50,000 rows now open in under a second on any device. Plus workspaces can hold 50,000 rows per database and Business 250,000, so this was not an edge case. It was the main case for our biggest teams.

Where the time went

We traced 400 slow opens from real workspaces (with permission, and with the content stripped). The pattern was the same every time. The client asked for every row, waited for all of them, sorted them, filtered them, then drew the 30 that fit on screen.

StepBeforeShare
Fetch all rows1.9 s56%
Sort and filter in the browser0.9 s26%
Compute formula columns0.4 s12%
Draw the first screen0.2 s6%
Median open of a 50,000-row table on a mid-range laptop, before the change.

Draw what fits, then stream

The fix is simple to say. The server now sorts and filters, sends the first 200 rows with the view, and streams the rest in the background while you read. Scrolling past the loaded rows asks for the next page before you reach it.

// Simplified: the view request now carries its own sort and filter.
const page = await db.view(viewId).rows({
  sort: view.sort,          // e.g. [{ property: "due", direction: "asc" }]
  filter: view.filter,      // evaluated server-side, permission-checked
  limit: 200,
  after: cursor,            // null for the first page
});
The view query. Formulas the view does not show are no longer computed.

The hard part was keeping edits instant. When you change a status on row 30, the row has to move to its new place in the sort before the server answers. We kept the client-side sort for rows already on screen, and let the server correct the order quietly if it disagrees.

The boring cache

Most opens are re-opens: the same person, the same view, an hour later. We now keep the first page of every view you opened in the last week on your device. A re-open draws from the cache in about 120 ms, then checks for changes.

The result

RowsBeforeAfter
1,0000.4 s0.2 s
10,0001.1 s0.4 s
50,0003.4 s0.8 s
250,00014.2 s1.3 s
Median time to first usable screen, same laptop, same workspaces.

Four times faster at 50,000 rows, ten times at 250,000. Sorting by a formula column no longer recalculates the whole table either. If you find a view that still feels slow, the support team will want the link.

H

Written by

Hana Sato

Engineer, databases, Montreal. Owns the page “Query planner”.

All posts

Keep reading

More from the blog.

Every post
  • Inside Folio5 min

    How we write specs at Folio.

    One page, four headings, and a section called “Not doing” that saves more time than the rest combined. Our spec template, with the reasons behind it.

    JJonas Brandt

  • Writing4 min

    Meeting notes that turn into work.

    Most meeting notes are a transcript nobody opens again. Three small habits turn them into decisions, owners and dates that land in the right table.

    MMarta Silva

  • Writing6 min

    Write for the person who joins next year.

    The best test for any document is a reader who wasn’t there and can’t ask. Notes on writing for them, from five years of building a place to write.

    IInes Duarte

Write it down once. Find it forever.

Folio is free for personal use. Teams pay per member who edits, and guests are always free.