I am using the JSONB field in my Postgresql database to store the next document. I have thousands of documents. I need to create reports with this data, but the search is very slow.
If I need to create a report indicating the new users of the month, I need to go through the entire document, comparing if the user is in one month and not in another.
Message Document:
[{"recipient":1,"user":4,"created_at":"2016-11-10","content":"Duis aliquam convallis nunc.","is_sender_user":true},
{"recipient":1,"user":18,"created_at":"2016-12-10","content":"Proin eu mi.","is_sender_user":false},
{"recipient":1,"user":4,"created_at":"2016-11-20","content":"In hac habitasse platea dictumstm.","is_sender_user":true},
{"recipient":1,"user":20,"created_at":"2016-12-14","content":"Donec ut dolor.","is_sender_user":true},
{"recipient":1,"user":13,"created_at":"2016-12-06","content":"Nulla mollis molestie lorem. Quisque ut erat. Curabitur gravida nisi at nibh.","is_sender_user":true}]
It would be better to create a User table and create a JSONB message field to hold your messages. Or how can I create my report using JSONB queries?
source
share