When designing a SQL table polymorphic references, it's preferable to create a composite index with the type column first. For example:
CREATE INDEX my_poly_ref ON upvote (target_type, target_id);
This is preferable because you'll more likely to query by a type without an id than by an id without a type. In fact I can't think of reason to do the latter, personally.