crypto-com / crypto-com/chain-indexing

Problem: view_transactions_total could be simplified with a materialized view

Open
#185 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
34
Forks
32
PR merge metrics
No merged PRs in 30d

Description

```sql
create materialized view view_transactions_total as (
select block_height as identity, count(id) as total from view_transactions group by block_height
);
```
after projection task updated `view_transactions`, call `refresh materialized view view_transactions_total`;

if you want to populate the zero rows, then something like this:
```sql
create materialized view view_transactions_total as (
select b.height, COALESCE(t.total, 0)
from view_blocks b left outer join
(select block_height as identity, count(id) as total from view_transactions group by block_height) t
on (t.identity=b.height)
);
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.