Skip to content

Commit

Permalink
indexer-alt: treat None as NULL (#20704)
Browse files Browse the repository at this point in the history
## Description

Pick out this change from the bigger #20482. `DEFAULT VALUE` is not
something we use, and treating `None` as `DEFAULT VALUE` means we have
to prepare different statements for each insert/update based on where
the `None`'s appear.

By treating `None` as `NULL`, we get to re-use prepared statements more,
and the query sampler will do a better job grouping similar
inserts/updates.

## Test plan

Run indexer on coin balances and object info, locally, for the first
10,000 checkpoints.

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
amnn authored Dec 30, 2024
1 parent 8d0699e commit 7a01d3e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
1 change: 1 addition & 0 deletions crates/sui-indexer-alt-schema/src/epochs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::schema::{kv_epoch_ends, kv_epoch_starts, kv_feature_flags, kv_protoco

#[derive(Insertable, Debug, Clone, FieldCount)]
#[diesel(table_name = kv_epoch_ends)]
#[diesel(treat_none_as_default_value = false)]
pub struct StoredEpochEnd {
pub epoch: i64,
pub cp_hi: i64,
Expand Down
14 changes: 0 additions & 14 deletions crates/sui-indexer-alt-schema/src/mod.rs

This file was deleted.

3 changes: 3 additions & 0 deletions crates/sui-indexer-alt-schema/src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::schema::{coin_balance_buckets, kv_objects, obj_info, obj_versions};

#[derive(Insertable, Debug, Clone, FieldCount)]
#[diesel(table_name = kv_objects, primary_key(object_id, object_version))]
#[diesel(treat_none_as_default_value = false)]
pub struct StoredObject {
pub object_id: Vec<u8>,
pub object_version: i64,
Expand Down Expand Up @@ -49,6 +50,7 @@ pub enum StoredCoinOwnerKind {

#[derive(Insertable, Debug, Clone, FieldCount)]
#[diesel(table_name = obj_info, primary_key(object_id, cp_sequence_number))]
#[diesel(treat_none_as_default_value = false)]
pub struct StoredObjInfo {
pub object_id: Vec<u8>,
pub cp_sequence_number: i64,
Expand All @@ -62,6 +64,7 @@ pub struct StoredObjInfo {

#[derive(Insertable, Debug, Clone, FieldCount)]
#[diesel(table_name = coin_balance_buckets, primary_key(object_id, cp_sequence_number))]
#[diesel(treat_none_as_default_value = false)]
pub struct StoredCoinBalanceBucket {
pub object_id: Vec<u8>,
pub cp_sequence_number: i64,
Expand Down

0 comments on commit 7a01d3e

Please sign in to comment.