sql - PostgrSQL: Create Index in JSON Array -


i pretty new postregsql , not familiar sql yet. im trying learn. in database want store huge json files (~2mio lines, 40mb) , later query them fast possible. right slow, figured indexing should trick. problem not know how index file since bit tricky. woking on whole day , starting desperate..

my db calles "replays" json column "replay_files"

so files this:

"replay": [     {         "data": {             "posx": 182,             "posy": 176,             "hero_name": "cdota_unit_hero_earthspirit"         },         "tick": 2252,         "type": "entity"     },     {         "data": {             "posx": 123,             "posy": 186,             "hero_name": "cdota_unit_hero_puck"         },         "tick": 2252,         "type": "entity"     }, ...alot more lines... ]} 

i tried entries heron_name: puck tried this:

select * replays r, json_array_elements(r.replay_file#>'{replay}') obj obj->'data'->>'hero_name' = 'cdota_unit_hero_puck';

which working smaller files. want index that:

create index hero_name_index on replays ((json_array_elements(r.replay_file#>'{replay}')->'data'->'hero_name);

but doesn work. have no idea how reach deep file , index stuff.

i hope understand problem since english isnt best , can me out here. dont know else try out.

kind regards , alot in advance peter


Comments