libeufin-bank-0006.sql (1780B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2024 Taler Systems SA 4 -- 5 -- TALER is free software; you can redistribute it and/or modify it under the 6 -- terms of the GNU General Public License as published by the Free Software 7 -- Foundation; either version 3, or (at your option) any later version. 8 -- 9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 -- A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 -- 13 -- You should have received a copy of the GNU General Public License along with 14 -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 16 BEGIN; 17 18 SELECT _v.register_patch('libeufin-bank-0006', NULL, NULL); 19 SET search_path TO libeufin_bank; 20 21 -- Add missing index for common queries 22 23 CREATE INDEX bank_accounts_public_index ON bank_accounts (bank_account_id) WHERE is_public = true; 24 COMMENT ON INDEX bank_accounts_public_index IS 'for listing public accounts'; 25 26 CREATE INDEX bank_account_transactions_index ON bank_account_transactions (bank_account_id, bank_transaction_id); 27 COMMENT ON INDEX bank_accounts_public_index IS 'for listing bank account''s transaction'; 28 29 CREATE INDEX bearer_tokens_index ON bearer_tokens USING btree (bank_customer, bearer_token_id); 30 COMMENT ON INDEX bearer_tokens_index IS 'for listing bank customer''s bearer token'; 31 32 CREATE INDEX cashout_operations_index ON cashout_operations USING btree (bank_account, cashout_id); 33 COMMENT ON INDEX cashout_operations_index IS 'for listing bank customer''s cashout operations'; 34 35 CREATE INDEX customers_deleted_index ON customers (customer_id) WHERE deleted_at IS NOT NULL; 36 COMMENT ON INDEX customers_deleted_index IS 'for garbage collection'; 37 38 COMMIT;