From 9054160bcba5d7ebd34c4e4a86b9510d72727e4a Mon Sep 17 00:00:00 2001 From: leenpaws Date: Thu, 18 Jun 2020 17:06:32 -0400 Subject: [PATCH] Revert "Add indices to speed up conseil" (#857) * Revert "Add indices to speed up conseil (#841)" This reverts commit 0e1602fa2fc53fef90c6a91b4c6dfa307b6e58a7. * Update conseil.sql * Add updated Tables.scala file * Update conseil.sql * Update slick tables definitions in accord to the sql schema Co-authored-by: PrathamRawat Co-authored-by: Ivano Pagano --- sql/conseil.sql | 8 ++--- .../cryptonomic/conseil/tezos/Tables.scala | 34 ++++++++----------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/sql/conseil.sql b/sql/conseil.sql index b8896538a..598b93a40 100644 --- a/sql/conseil.sql +++ b/sql/conseil.sql @@ -186,7 +186,7 @@ CREATE TABLE tezos.accounts_history ( is_activated boolean NOT NULL DEFAULT false, is_active_baker boolean ); -CREATE INDEX ix_account_id ON tezos.accounts_history USING btree (account_id); + -- -- Name: accounts_checkpoint; Type: TABLE; Schema: tezos; Owner: - -- @@ -427,9 +427,6 @@ CREATE TABLE tezos.operations ( utc_time character varying NOT NULL ); -CREATE INDEX ix_manager_pubkey ON tezos.operations USING btree (manager_pubkey); -CREATE INDEX ix_operation_group_hash ON tezos.operations USING btree (operation_group_hash); -CREATE INDEX ix_originated_contracts ON tezos.operations USING btree (originated_contracts); -- -- Name: operations_operation_id_seq; Type: SEQUENCE; Schema: tezos; Owner: - @@ -555,13 +552,14 @@ ALTER TABLE ONLY tezos.operations -- CREATE INDEX baking_rights_level_idx ON tezos.baking_rights USING btree (level); - +CREATE INDEX ix_delegate_priority ON tezos.baking_rights USING btree (delegate, priority); -- -- Name: endorsing_rights_level_idx; Type: INDEX; Schema: tezos; Owner: - -- CREATE INDEX endorsing_rights_level_idx ON tezos.endorsing_rights USING btree (level); +CREATE INDEX ix_delegate ON tezos.endorsing_rights USING btree (delegate); -- diff --git a/src/main/scala/tech/cryptonomic/conseil/tezos/Tables.scala b/src/main/scala/tech/cryptonomic/conseil/tezos/Tables.scala index d1003be20..981866776 100644 --- a/src/main/scala/tech/cryptonomic/conseil/tezos/Tables.scala +++ b/src/main/scala/tech/cryptonomic/conseil/tezos/Tables.scala @@ -415,11 +415,8 @@ trait Tables { /** Database column is_active_baker SqlType(bool), Default(None) */ val isActiveBaker: Rep[Option[Boolean]] = column[Option[Boolean]]("is_active_baker", O.Default(None)) - /** Index over (accountId) (database name ix_account_id) */ - val index1 = index("ix_account_id", accountId) - /** Index over (blockId) (database name ix_accounts_history_block_id) */ - val index2 = index("ix_accounts_history_block_id", blockId) + val index1 = index("ix_accounts_history_block_id", blockId) } /** Collection-like TableQuery object for table AccountsHistory */ @@ -967,6 +964,9 @@ trait Tables { /** Index over (level) (database name baking_rights_level_idx) */ val index1 = index("baking_rights_level_idx", level) + + /** Index over (delegate,priority) (database name ix_delegate_priority) */ + val index2 = index("ix_delegate_priority", (delegate, priority)) } /** Collection-like TableQuery object for table BakingRights */ @@ -1592,6 +1592,9 @@ trait Tables { /** Index over (level) (database name endorsing_rights_level_idx) */ val index1 = index("endorsing_rights_level_idx", level) + + /** Index over (delegate) (database name ix_delegate) */ + val index2 = index("ix_delegate", delegate) } /** Collection-like TableQuery object for table EndorsingRights */ @@ -2388,35 +2391,26 @@ trait Tables { onDelete = ForeignKeyAction.NoAction ) - /** Index over (managerPubkey) (database name ix_manager_pubkey) */ - val index1 = index("ix_manager_pubkey", managerPubkey :: HNil) - - /** Index over (operationGroupHash) (database name ix_operation_group_hash) */ - val index2 = index("ix_operation_group_hash", operationGroupHash :: HNil) - /** Index over (blockLevel) (database name ix_operations_block_level) */ - val index3 = index("ix_operations_block_level", blockLevel :: HNil) + val index1 = index("ix_operations_block_level", blockLevel :: HNil) /** Index over (cycle) (database name ix_operations_cycle) */ - val index4 = index("ix_operations_cycle", cycle :: HNil) + val index2 = index("ix_operations_cycle", cycle :: HNil) /** Index over (delegate) (database name ix_operations_delegate) */ - val index5 = index("ix_operations_delegate", delegate :: HNil) + val index3 = index("ix_operations_delegate", delegate :: HNil) /** Index over (destination) (database name ix_operations_destination) */ - val index6 = index("ix_operations_destination", destination :: HNil) + val index4 = index("ix_operations_destination", destination :: HNil) /** Index over (kind) (database name ix_operations_kind) */ - val index7 = index("ix_operations_kind", kind :: HNil) + val index5 = index("ix_operations_kind", kind :: HNil) /** Index over (source) (database name ix_operations_source) */ - val index8 = index("ix_operations_source", source :: HNil) + val index6 = index("ix_operations_source", source :: HNil) /** Index over (timestamp) (database name ix_operations_timestamp) */ - val index9 = index("ix_operations_timestamp", timestamp :: HNil) - - /** Index over (originatedContracts) (database name ix_originated_contracts) */ - val index10 = index("ix_originated_contracts", originatedContracts :: HNil) + val index7 = index("ix_operations_timestamp", timestamp :: HNil) } /** Collection-like TableQuery object for table Operations */