tursodatabase / tursodatabase/libsql

Optimize COUNT(*) in terms of rows read metrics

Open
#160 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
17.2k
Forks
531
Avg merge
1h 12m
Merged PRs (30d)
1

Description

Issuing a SELECT COUNT(*) will currently bump the number of rows read linearly to the number of rows. COUNT() results can be rather easily cached however (esp. without any WHERE clause), and then we could offer constant time COUNT () support which only reads a single row.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how SELECT COUNT() currently contributes to rows-read metrics, comparing queries with and without a WHERE clause. Define completion as COUNT() avoiding linear row reads where caching is valid, reporting constant-time behavior and reading only one row, while preserving correct results.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, sqlite
Domain
databases, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.