-- table junk7 id | data ----+----------------------------------------------------------------------------------------------------- 1 | {"email": "syya@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} 2 | {"email": "lzda@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} 3 | {"email": "ygiu@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} (3 rows) count ---------- 10000000 (1 row) id | data ---------+----------------------------------------------------------------------------------------------------- 408723 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} 1008165 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} [...] 9380475 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} 9824614 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} (26 rows) Time: 4071.469 ms id | data ---------+----------------------------------------------------------------------------------------------------- 408723 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} 1008165 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} [...] 9380475 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} 9824614 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} (26 rows) Time: 3879.432 ms QUERY PLAN ---------------------------------------------------------------------------------------------------------------- Seq Scan on junk7 (cost=0.00..583103.10 rows=10004 width=108) (actual time=144.428..3894.673 rows=26 loops=1) Filter: (data @> '{"email": "abcd@test.com"}'::jsonb) Rows Removed by Filter: 9999974 Planning time: 0.034 ms Execution time: 3894.709 ms (5 rows) CREATE INDEX Time: 82600.671 ms [...] 9380475 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} 9824614 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} (26 rows) Time: 23.768 ms id | data ---------+----------------------------------------------------------------------------------------------------- 408723 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} 1008165 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} [...] 9380475 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} 9824614 | {"email": "abcd@test.com", "price": "15", "title": "Mt Thing XYZ", "order_code": "0165-02675-4565"} (26 rows) Time: 4.792 ms QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------- Bitmap Heap Scan on junk7 (cost=125.49..35457.45 rows=9999 width=108) (actual time=3.412..3.490 rows=26 loops=1) Recheck Cond: (data @> '{"email": "abcd@test.com"}'::jsonb) Heap Blocks: exact=26 -> Bitmap Index Scan on junk7_gin_idx (cost=0.00..122.99 rows=9999 width=0) (actual time=3.395..3.395 rows=26 loops=1) Index Cond: (data @> '{"email": "abcd@test.com"}'::jsonb) Planning time: 0.832 ms Execution time: 3.544 ms (7 rows) Time: 4.895 ms List of relations Schema | Name | Type | Owner | Table | Size | Description --------+---------------+-------+----------+-------+---------+------------- public | junk7 | table | aardvark | | 3579 MB | public | junk7_gin_idx | index | aardvark | junk7 | 177 MB | (2 rows)