MostlyData_Solana CU - vote txs
    Updated 2025-03-13
    /*
    https://solana.com/it/developers/guides/advanced/how-to-optimize-compute

    Solana has a max of 48000000 units per block

    */
    with date_filter as (
    select
    case
    when '{{n_days}}' != 0 then current_date() - interval '{{n_days}} days'
    else cast('{{start_date}}' as timestamp)
    end as start_date,
    case
    when '{{n_days}}' != 0 then current_date()
    else cast('{{end_date}}' as timestamp)
    end as end_date
    )

    ,compute_unit_data_raw as(
    select
    date_trunc('hour', ft.block_timestamp) as dt,
    ft.block_id,
    --sum(units_consumed) as cu,
    sum(ft.units_consumed) / 48000000 * 100 as share_of_max_cu
    from solana.core.fact_transactions ft
    join date_filter df
    on ft.block_timestamp between df.start_date and df.end_date

    group by 1,2
    )

    ,cu_w_vote_infos as(
    select
    cu.dt,
    cu.block_id,
    QueryRunArchived: QueryRun has been archived