```
=# create index on events (( params->>'username' ));
CREATE INDEX
zbynek
=# explain select * from events where params->>'username' = 'zwn';
                                   QUERY PLAN                                   
--------------------------------------------------------------------------------
 Bitmap Heap Scan on events  (cost=6.27..455.38 rows=255 width=76)
   Recheck Cond: ((params ->> 'username'::text) = 'zwn'::text)
   ->  Bitmap Index Scan on events_expr_idx  (cost=0.00..6.21 rows=255 width=0)
         Index Cond: ((params ->> 'username'::text) = 'zwn'::text)
(4 rows)
```
Actually postgres does functional indexes meaning that you can index the result of any immutable function.