Guest User

Untitled

a guest
Apr 24th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. {"state": "initialize_done_state", ... }
  2.  
  3. CREATE INDEX index_activities_on_data ON activities USING gin (data)
  4.  
  5. select count(*)
  6. from activities a
  7. where a.created_at >= (date_trunc('month', current_date)::timestamp AT TIME ZONE 'MSK') and
  8. --a.data ->> 'state' = 'issued_success_state';
  9. a.data @> '{ "state": "issued_success_state" }';
  10.  
  11. Aggregate (cost=406.91..406.92 rows=1 width=8)
  12. -> Bitmap Heap Scan on activities a (cost=32.75..406.67 rows=95 width=0)
  13. Recheck Cond: (data @> '{"state": "issued_success_state"}'::jsonb)
  14. Filter: (created_at >= timezone('MSK'::text, (date_trunc('month'::text, (('now'::cstring)::date)::timestamp with time zone))::timestamp without time zone))
  15. -> Bitmap Index Scan on index_activities_on_data (cost=0.00..32.73 rows=364 width=0)
  16. Index Cond: (data @> '{"state": "issued_success_state"}'::jsonb)
  17.  
  18. Aggregate (cost=59093.42..59093.43 rows=1 width=8)
  19. -> Seq Scan on activities a (cost=0.00..59092.23 rows=477 width=0)
  20. Filter: (((data ->> 'state'::text) = 'issued_success_state'::text) AND (created_at >= timezone('MSK'::text, (date_trunc('month'::text, (('now'::cstring)::date)::timestamp with time zone))::timestamp without time zone)))
  21.  
  22. CREATE INDEX ON activities ((data->>'state'));
Add Comment
Please, Sign In to add comment