0

I have a bunch of tables in my app, and I have a view that basically loads all of them via associations, The problem is I end up with something like 100 queries if its not cached. Is there a way just to do 1 query and load the entire database into memory, I tried .includes but it still does queries for .count and other stuff. .entries doesn't seem to work. Any tips and help are greatly apreciated.

My model associations are like so (many>one, one=one):

  • Clients < Projects < Activities = Assignments = Users
  • Assignments < Tasks
  • 1
    Could you provide more information about your schema? You wish to load the entire database? This would be all of the tables and all of their associations? – bideowego May 05 '16 at 17:12
  • edited the question with more information, yes all the tables, their contents . Formated in a way that make sense, according to their associations – Sergey Andreev May 05 '16 at 17:19
  • Have you tried nesting your `.includes` like [this answer](http://stackoverflow.com/a/24397716/5113832) shows? – bideowego May 05 '16 at 17:58
  • I'm curious, what is the reason is you want to load the **entire** database? Is it perhaps to use as a JSON object on the front-end? – bideowego May 05 '16 at 18:01

1 Answers1

0

Alright, so the thing was: includes were working fine

It's just when you include and run .order or .count it still queries the database for some reason I substituted .count to .size and .order to .sort

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459