You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This query doesn't use an index because we don't have an index covering all of the filtered columns. The combined index doesn't include the related accounts, while the related accounts index doesn't include other columns:
CREATEINDEXix_runtime_events_roundONchain.runtime_events(runtime, round); -- for sorting by round, when there are no filters applied
CREATEINDEXix_runtime_events_tx_hashONchain.runtime_events USING hash (tx_hash);
CREATEINDEXix_runtime_events_tx_eth_hashONchain.runtime_events USING hash (tx_eth_hash);
CREATEINDEXix_runtime_events_related_accountsONchain.runtime_events USING gin(related_accounts); -- for fetching account activity for a given account
CREATEINDEXix_runtime_events_evm_log_signatureONchain.runtime_events(runtime, evm_log_signature, round); -- for fetching a certain event type, eg Transfers
CREATEINDEXix_runtime_events_evm_log_paramsONchain.runtime_events USING gin(evm_log_params);
A similar issue is querying consensus events with "rel=". The gin index (which cannot include the round) is not efficient enough for any address with high number of events, since those then need to be sorted in memory. Maybe this could be improved with some db parameter updates.
On the tokens page, querying all the transfers uses the following API call: https://nexus.oasis.io/v1/sapphire/events?offset=0&limit=10&type=evm.log&evm_log_signature=ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef&rel=0x08Fe02Da45720f754e6FCA338eC1286e860d2d2f
This query doesn't use an index because we don't have an index covering all of the filtered columns. The combined index doesn't include the related accounts, while the related accounts index doesn't include other columns:
nexus/storage/migrations/01_runtimes.up.sql
Lines 172 to 183 in 7170c28
Actually, thinking about it a bit more, the above query is not actually the correct one, as it queries all
ERC20Transfer
events, where related account is the contract address. This would also include any other token transfers which would be sent to the contract address. The frontend should use the following query instead: https://nexus.oasis.io/v1/sapphire/events?offset=0&limit=10&type=evm.log&evm_log_signature=ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef&contract_address=0x08Fe02Da45720f754e6FCA338eC1286e860d2d2f (noterel
replaced withcontract_address
).However, the indexing problem remains, we need an index for evm log events, something like:
However, on the Accounts page, token-transfers sub-page (e.g. https://explorer.oasis.io/mainnet/sapphire/address/0x1265997E14Eb5e801eA46C360D964203d05C1821/token-transfers) , we also use the events query with same filters: https://nexus.oasis.io/v1/sapphire/events?offset=0&limit=10&type=evm.log&evm_log_signature=ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef&rel=0x1265997E14Eb5e801eA46C360D964203d05C1821
In this case, using
rel
is correct, so we should update the indexes to also support this case.The text was updated successfully, but these errors were encountered: