[BUGFIX] Avoid redundant SQL queries in ReferenceIndex