cockroachdb / cockroachdb/cockroach

views: use follower reads for materialized views by default or optionally

Open
#98,054 0 comments 0 reactions 0 assignees View on GitHub
C-enhancement T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Is your feature request related to a problem? Please describe.**
I'm seeing my materialized view queries run about 2x better when they're wrapped in a follower read transaction. Considering materialized views work on stale data (assuming less frequent refresh), it can benefit from running MR with FR. Nothing prevents me from doing the following:

```sql
BEGIN PRIORITY HIGH AS OF SYSTEM TIME follower_read_timestamp();
SELECT FROM MR;
COMMIT;
```

but executing implicitly with FR is probably a better DX.

**Describe the solution you'd like**

Executing a materialized view should implicitly read from the follower read replica.

**Describe alternatives you've considered**

surprisingly this works `SELECT * FROM MR AS OF SYSTEM TIME follower_read_timestamp();`.

Jira issue: CRDB-25052

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.