diff --git a/hive/db/db_state.py b/hive/db/db_state.py
index 65b6575ad5d6aed2c9e56b116eae761c05429f85..b8b66afca3afa23f41795602e8f5f19441022047 100644
--- a/hive/db/db_state.py
+++ b/hive/db/db_state.py
@@ -124,7 +124,9 @@ class DbState:
             'hive_post_tags_tag_id_idx',
 
             'hive_votes_voter_id_post_id_idx',
-            'hive_votes_post_id_voter_id_idx'
+            'hive_votes_post_id_voter_id_idx',
+
+            'hive_reputation_data_block_num_idx'
         ]
 
         to_return = []
diff --git a/hive/db/schema.py b/hive/db/schema.py
index 4155d42a7e56e90113a704968851e93f46a6a388..cd4673e94acde69a9dc537c8dba6a49e5d7df7b4 100644
--- a/hive/db/schema.py
+++ b/hive/db/schema.py
@@ -70,7 +70,8 @@ def build_metadata():
         sa.Column('rshares', sa.BigInteger, nullable=False),
         sa.Column('block_num', sa.Integer,  nullable=False),
 
-        sa.Index('hive_reputation_data_author_permlink_voter_idx', 'author_id', 'permlink', 'voter_id')
+        sa.Index('hive_reputation_data_author_permlink_voter_idx', 'author_id', 'permlink', 'voter_id'),
+        sa.Index('hive_reputation_data_block_num_idx', 'block_num')
     )
 
     sa.Table(
diff --git a/hive/db/sql_scripts/calculate_account_reputations.sql b/hive/db/sql_scripts/calculate_account_reputations.sql
index 31d8f8f4808daf004db4bcb53c7c54a519c1de8b..eafc1851e6680fc7b4324ab92f68b041d6aa89fb 100644
--- a/hive/db/sql_scripts/calculate_account_reputations.sql
+++ b/hive/db/sql_scripts/calculate_account_reputations.sql
@@ -5,12 +5,15 @@ CREATE TYPE AccountReputation AS (id int, reputation bigint, is_implicit boolean
 DROP FUNCTION IF EXISTS public.calculate_account_reputations;
 
 CREATE OR REPLACE FUNCTION public.calculate_account_reputations(
-  in _first_block_num INTEGER,
-  in _last_block_num INTEGER,
-  in _tracked_account varchar = null)
+  _first_block_num integer,
+  _last_block_num integer,
+  _tracked_account character varying DEFAULT NULL::character varying)
     RETURNS SETOF accountreputation 
     LANGUAGE 'plpgsql'
-    STABLE
+
+    COST 100
+    STABLE 
+    ROWS 1000
 AS $BODY$
 DECLARE
   __vote_data RECORD;
@@ -97,9 +100,12 @@ BEGIN
 
     RETURN QUERY
       SELECT id, Reputation, is_implicit
-      FROM unnest(__account_reputations);
+      FROM unnest(__account_reputations)
+    WHERE Reputation IS NOT NULL
+    ;
 END
-$BODY$;
+$BODY$
+;
 
 DROP FUNCTION IF EXISTS public.update_account_reputations;