CREATE TABLE test ( doc JSONB NOT NULL ); CREATE INDEX ON test USING GIN (doc); INSERT INTO test (doc) SELECT ('{"id" : "' || gen_random_uuid() || '", "timestamp" : "' || (now() + (n || ' microseconds')::INTERVAL) || '", "flag1" : ' || (case when (n % 2 = 0) then 'true' else 'false' end) || ', "flag2" : ' || (case when (n % 23 = 0) then 'true' else 'false' end) || ', "string1" : "testa' || (n % 13) || '", "string2" : "testb' || (n % 23) || '"}')::json FROM (select generate_series(1, 100000) as n) AS x; ANALYSE test;