Answer the question
In order to leave comments, you need to log in
How to build a multidimensional array from a PostgreSQL database?
Good afternoon.
I have a data tree in the database according to the parent-child model. How can I select an entire tree (or a single branch) from the database and build a multidimensional array?
Task. There is a structure, regions-> cities-> manager-> outlet. The structure is stored in one table. Another table stores sales data for the outlet for each day. The third table stores plans for each outlet, for each manager, for each city and for each region for the month.
All three tables are combined in one query (WITH RECURSIVE). The output is an array. What is the fastest way to display it? I think that to build a multidimensional array, the nesting of which will depend on the number of levels in the database, and then display it by simply enumerating the array. Or is it easier to convert the array to JSON and it will be faster this way?
Please tell me the fastest way.
Thank you.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question