0

I have such a network structure : There is a person, there are his relatives and relatives of his relatives. I need to do queries in this network like bring the ones older than 30 years old or show the relationship with Jason and Anna. And every person in the network has a list of their relatives as a property.

All of the network information is stored in a non-graph database. So would I have a better performance if I once generate whole network to a json file and then query the JSON file in the front end instead of sending the query to the database and then getting the result? Thanks in advance.

jason
  • 6,962
  • 36
  • 117
  • 198
  • How big is the dataset? If you have ten people and it never grows, then this approach would be fine. If you have ten million, then no. – Harun Jul 19 '17 at 17:37
  • A lot of this problem would rely on data size and how you're currently querying (there may be an optimizer working in the background), generally for small data sets bringing the whole JSON in would be fine – yanman1234 Jul 19 '17 at 17:39
  • See [this **closed** question](https://stackoverflow.com/questions/7985145/mysql-vs-json-why) which might be considered the original to this duplicate. Try to be more specific about your concerns regarding performance to avoid a similar fate. Have you run any performance tests? – Fred Gandt Jul 19 '17 at 17:40
  • @FredGandt I ran such a test : Bring X's relatives. X has about 500 relatives so I had to make 500 calls to the database. And as you can guess it had a terrible performance. Most probably my way of attacking the problem was terrible as well. But I want to reduce the number database calls. That's why I thought about dumping all the data into JSON. – jason Jul 19 '17 at 17:52
  • 500 queries for the relatives doesn't sound like a good idea; my SQL is beyond rusty, but a quick search turned up [this question](https://stackoverflow.com/questions/15910905/sql-database-for-related-family-members) suggesting what I was thinking wasn't far off right. Regardless, it would probably be best to add a [Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve) of the data you're dealing with, and some of the code you've tried using to do it. The more specific the question, the better the answers can be. P.S. Add new info to the question, not as a comment. – Fred Gandt Jul 19 '17 at 18:14

0 Answers0