#4279·lancedb

perf(python): fetch_blob_files has no read-ahead control, so scattered reads fetch 60-115x the requested bytes

Author: XuanwoCreated Sep 23, 2026Updated Sep 28, 2026
LabelsPythonperformance

Problem

BlobFile handles from fetch_blob_files always use Lance's 512 KiB read-ahead, and lancedb gives no way to change or disable it. Sequential reads are efficient since lance-format/lance#9251, but scattered reads fetch far more than they use.

Measured on an 8 MiB dedicated blob on the local filesystem, counting get_range calls in LANCEDB_LOG=debug:

access pattern bytes used get_range calls bytes fetched
100 × (seek + read 4 KiB) at random offsets 409,600 95 46,751,073 (114x)
100 × read_range 4 KiB at the same offsets 409,600 100 409,600 (1x)
read 64 B at the end, then 64 B at the start 128 2 524,352
zipfile.ZipFile(handle).read(one_member) 32,768 4 539,734
backward scan in 8 KiB steps 8 MiB 1024 520,355,840 (62x)

Formats that seek around (zip, tar, mp4, parquet footers) pay this on every access, and on object storage each fetch is also a billed request.

Root cause

  • lancedb: fetch_blob_files (Python sync and async, and Rust in rust/lancedb/src/blob.rs) takes no read-ahead parameter, and lancedb._blob.BlobFile doesn't expose Lance's set_buffer_size. Lance itself exposes take_blobs(..., buffer_size=0) in Python.
  • lance (rust/lance/src/dataset/blob.rs): a cursor miss fetches max(buffer_size, need). A seek outside the current window drops the window, and a cursor before the window start is not served from it, so a backward scan refetches 512 KiB on every step.

Fix direction

  1. lancedb: add a buffer_size (or read_ahead) option to fetch_blob_files, and/or BlobFile.set_buffer_size. Document that read_range bypasses the buffer and is the right call for random access.
  2. lance (design question, can be split into a lance issue): keep the old window on a backward seek and refill only the gap, or grow read-ahead only after sequential hits.

Environment

lancedb 0.40.0b5, pylance 13.0.0b8, local filesystem (S3 not measured). Same code on main in both repos.

Found during the Blob V2 bug bash (2026-09-23).