|
| 1 | +-- Clearing 3 useless index taking around 6GB on testnet database: |
| 2 | +-- idx_ciphertexts_handle_not_null and idx_ciphertexts_ciphertext_null, idx_computations_pk |
| 3 | +-- |
| 4 | +-- Stat of index used on testnet database 'coprocessor' to identify unused indexes |
| 5 | + |
| 6 | +-- coprocessor=> SELECT |
| 7 | +-- schemaname, |
| 8 | +-- relname AS table_name, |
| 9 | +-- indexrelname AS index_name, |
| 10 | +-- pg_size_pretty(pg_relation_size(indexrelid)) AS index_size, |
| 11 | +-- idx_scan, |
| 12 | +-- idx_tup_read, |
| 13 | +-- idx_tup_fetch, |
| 14 | +-- last_idx_scan |
| 15 | +-- FROM pg_stat_user_indexes |
| 16 | +-- WHERE last_idx_scan IS NULL -- Never scanned |
| 17 | +-- OR last_idx_scan < (NOW() - INTERVAL '1 hour') -- Or scanned more than 1 hour ago |
| 18 | +-- ORDER BY |
| 19 | +-- last_idx_scan IS NULL DESC, -- Never-scanned first |
| 20 | +-- last_idx_scan ASC NULLS FIRST, -- Then oldest scans |
| 21 | +-- pg_relation_size(indexrelid) DESC, -- Largest indexes first (for impact assessment) |
| 22 | +-- idx_scan ASC, |
| 23 | +-- indexrelname ASC; |
| 24 | +-- schemaname | table_name | index_name | index_size | idx_scan | idx_tup_read | idx_tup_fetch | last_idx_scan |
| 25 | +-- ------------+-----------------------+-----------------------------------------------------------------+------------+----------+--------------+---------------+------------------------------- |
| 26 | +-- public | ciphertexts | idx_ciphertexts_handle_not_null | 1492 MB | 0 | 0 | 0 | |
| 27 | +-- public | computations | computations_errors_index | 424 MB | 0 | 0 | 0 | |
| 28 | +-- public | pbs_computations | idx_pbs_computations_pending_created_at | 273 MB | 0 | 0 | 0 | |
| 29 | +-- public | computations | idx_computations_is_allowed | 51 MB | 0 | 0 | 0 | |
| 30 | +-- public | verify_proofs | idx_verify_proofs_transactions | 160 kB | 0 | 0 | 0 | |
| 31 | +-- public | _sqlx_migrations | _sqlx_migrations_pkey | 16 kB | 0 | 0 | 0 | |
| 32 | +-- public | delegate_user_decrypt | idx_delegate_user_decrypt_block_hash | 16 kB | 0 | 0 | 0 | |
| 33 | +-- public | delegate_user_decrypt | idx_delegate_user_decrypt_on_gateway_reorg_out | 16 kB | 0 | 0 | 0 | |
| 34 | +-- public | ciphertexts | idx_ciphertexts_ciphertext_null | 8192 bytes | 0 | 0 | 0 | |
| 35 | +-- public | dependence_chain | idx_dependence_chain_processing_by_worker | 808 kB | 2 | 449 | 2 | 2025-12-30 20:05:13.493114+00 |
| 36 | +-- public | dependence_chain | idx_dependence_chain_worker_id | 3056 kB | 4080743 | 886000474 | 4080716 | 2025-12-31 12:57:15.207206+00 |
| 37 | +-- public | input_blobs | input_blobs_pkey | 8192 bytes | 1 | 0 | 0 | 2025-12-31 14:36:14.026587+00 |
| 38 | +-- public | ciphertexts | idx_ciphertexts_ciphertext128_null | 128 MB | 1 | 8604467 | 1311439 | 2026-01-06 11:23:56.187617+00 |
| 39 | +-- public | computations | idx_computations_pk | 4521 MB | 3577647 | 5509663 | 3577647 | 2026-01-08 20:17:26.877748+00 |
| 40 | +-- public | computations | idx_computations_dependence_chain | 105 MB | 3135753 | 7155134577 | 7025082442 | 2026-01-08 20:17:27.586493+00 |
| 41 | +-- public | dependence_chain | idx_pending_dependence_chain | 816 kB | 255220 | 23385243 | 0 | 2026-01-10 15:28:01.301323+00 |
| 42 | +-- public | delegate_user_decrypt | delegate_user_decrypt_delegator_delegate_contract_address_d_key | 40 kB | 409 | 409 | 361 | 2026-01-13 23:53:18.702157+00 |
| 43 | +-- public | delegate_user_decrypt | delegate_user_decrypt_pkey | 16 kB | 435 | 26 | 26 | 2026-01-13 23:53:18.702157+00 |
| 44 | +-- public | computations | idx_computations_created_at | 40 MB | 39783 | 246356585 | 140456265 | 2026-01-15 16:29:30.086643+00 |
| 45 | +-- public | verify_proofs | idx_verify_proofs_verified_retry | 184 kB | 34911 | 8948564 | 13991 | 2026-01-15 21:26:40.375146+00 |
| 46 | +-- public | ciphertexts | idx_ciphertexts_created_at | 83 MB | 47827 | 11448129 | 4619012 | 2026-01-16 03:41:46.042194+00 |
| 47 | +-- public | tenants | tenants_by_api_key | 16 kB | 194 | 194 | 194 | 2026-01-16 03:41:46.042194+00 |
| 48 | +-- public | dependence_chain | idx_dependence_chain_last_updated_at | 144 kB | 13 | 13162 | 16 | 2026-01-19 09:53:07.083768+00 |
| 49 | + |
| 50 | +-- idx_ciphertexts_handle_not_null and idx_ciphertexts_ciphertext_null cannot be used, since ciphertext can't be null |
| 51 | + |
| 52 | +DROP INDEX IF EXISTS idx_ciphertexts_handle_not_null; |
| 53 | +DROP INDEX IF EXISTS idx_ciphertexts_ciphertext_null; |
| 54 | + |
| 55 | +-- coprocessor=> \d ciphertexts |
| 56 | +-- Table « public.ciphertexts » |
| 57 | +-- Colonne | Type | Collationnement | NULL-able | Par défaut |
| 58 | +-- --------------------+-----------------------------+-----------------+-----------+------------ |
| 59 | +-- tenant_id | integer | | not null | |
| 60 | +-- handle | bytea | | not null | |
| 61 | +-- ciphertext | bytea | | not null | |
| 62 | +-- ciphertext_version | smallint | | not null | |
| 63 | +-- ciphertext_type | smallint | | not null | |
| 64 | +-- input_blob_hash | bytea | | | |
| 65 | +-- input_blob_index | integer | | not null | 0 |
| 66 | +-- created_at | timestamp without time zone | | | now() |
| 67 | +-- ciphertext128 | bytea | | | |
| 68 | +-- Index : |
| 69 | +-- "ciphertexts_pkey" PRIMARY KEY, btree (tenant_id, handle, ciphertext_version) |
| 70 | +-- "ciphertexts_handle_hash_idx" hash (handle) |
| 71 | +-- "idx_ciphertexts_ciphertext128_null" btree (ciphertext128) WHERE ciphertext128 IS NULL |
| 72 | +-- "idx_ciphertexts_ciphertext_null" btree (ciphertext) WHERE ciphertext IS NULL |
| 73 | +-- "idx_ciphertexts_created_at" btree (created_at) WHERE ciphertext128 IS NOT NULL |
| 74 | +-- "idx_ciphertexts_handle_not_null" btree (handle) WHERE ciphertext IS NOT NULL |
| 75 | + |
| 76 | +-- idx_computations_pk duplicate the primary key so it can be removed |
| 77 | + |
| 78 | +-- \d computations |
| 79 | +-- Table « public.computations » |
| 80 | +-- Colonne | Type | Collationnement | NULL-able | Par défaut |
| 81 | +-- ----------------------+-----------------------------+-----------------+-----------+--------------- |
| 82 | +-- tenant_id | integer | | not null | |
| 83 | +-- output_handle | bytea | | not null | |
| 84 | +-- dependencies | bytea[] | | not null | |
| 85 | +-- fhe_operation | smallint | | not null | |
| 86 | +-- created_at | timestamp without time zone | | not null | now() |
| 87 | +-- completed_at | timestamp without time zone | | | |
| 88 | +-- is_scalar | boolean | | not null | |
| 89 | +-- is_completed | boolean | | not null | false |
| 90 | +-- is_error | boolean | | not null | false |
| 91 | +-- error_message | text | | | |
| 92 | +-- transaction_id | bytea | | not null | '\x00'::bytea |
| 93 | +-- dependence_chain_id | bytea | | | |
| 94 | +-- is_allowed | boolean | | not null | false |
| 95 | +-- schedule_order | timestamp without time zone | | not null | now() |
| 96 | +-- uncomputable_counter | smallint | | not null | 1 |
| 97 | +-- Index : |
| 98 | +-- "computations_pkey" PRIMARY KEY, btree (tenant_id, output_handle, transaction_id) |
| 99 | +-- "computations_completed_index" btree (is_completed) |
| 100 | +-- "computations_errors_index" btree (is_error) |
| 101 | +-- "idx_computations_created_at" btree (created_at) WHERE is_completed = false |
| 102 | +-- "idx_computations_dependence_chain" btree (dependence_chain_id) WHERE is_completed = false AND is_error = false |
| 103 | +-- "idx_computations_is_allowed" btree (is_allowed) WHERE is_completed = false |
| 104 | +-- "idx_computations_pk" btree (tenant_id, output_handle, transaction_id) |
| 105 | +-- "idx_computations_schedule_order" btree (schedule_order) WHERE is_completed = false |
| 106 | +-- "idx_computations_transaction_id" btree (transaction_id) |
| 107 | +-- Triggers : |
| 108 | +-- work_updated_trigger_from_computations_insertions AFTER INSERT ON computations FOR EACH STATEMENT EXECUTE FUNCTION notify_work_available() |
| 109 | + |
| 110 | +DROP INDEX IF EXISTS idx_computations_pk; |
0 commit comments