Poor Query performance in postgresql 9.3
This is an analytics query, analytics queries are never simple in terms of how much data they need to examine.

The where a.statename='Karnataka' is redundant, because it was already in CREATE MATERIALIZED VIEW and repeating it in your query has no effect, since it will match all rows. PostgreSQL sees this from cardinality and knows it needs to scan the full table.

Also, no index will help you here since you are touching a large portion of table. Indexes only work when touching small amounts of data.

If you run this query often, you need to cache it. If a value needs to be exact even as the original records are updated, you need a trigger.