Add indices for tx_to and tx_from (#112)

This commit is contained in:
Matt K 2017-12-20 16:58:37 -06:00 committed by GitHub
parent 24bc83a448
commit a786241c8c
6 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1 @@
DROP INDEX tx_to_index;

View File

@ -0,0 +1 @@
CREATE INDEX tx_to_index ON transactions(tx_to);

View File

@ -0,0 +1 @@
DROP INDEX tx_from_index;

View File

@ -0,0 +1 @@
CREATE INDEX tx_from_index ON transactions(tx_from);

View File

@ -353,6 +353,20 @@ CREATE INDEX block_number_index ON blocks USING btree (block_number);
CREATE INDEX node_id_index ON blocks USING btree (node_id);
--
-- Name: tx_from_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX tx_from_index ON transactions USING btree (tx_from);
--
-- Name: tx_to_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX tx_to_index ON transactions USING btree (tx_to);
--
-- Name: transactions blocks_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--

View File

@ -334,6 +334,9 @@ func AssertRepositoryBehavior(buildRepository func(node core.Node) repositories.
repository.CreateContract(core.Contract{Hash: "x123"})
contract, err := repository.FindContract("x123")
Expect(err).ToNot(HaveOccurred())
sort.Slice(contract.Transactions, func(i, j int) bool {
return contract.Transactions[i].Hash < contract.Transactions[j].Hash
})
Expect(contract.Transactions).To(
Equal([]core.Transaction{
{Hash: "TRANSACTION1", To: "x123"},