Geez, I had seen that article before, and was looking for it today, but
for some reason I couldn’t locate it when I needed it (doh!). A bit
late, as I already figured a way, but Thanks just same –
I think I ended up doing it somewhat differently - this article doesn’t
display everything so I can’t be sure. Since I’ve already completed this
I didn’t replicate their approach so I’m not exactly sure what’s missing
in this howto.
Anyway, all I did was create a new model for each relationship R1, R2,
…, R5 against the same table R and then within each of these new
models used set_table_name R and set_primary_id. Then it was a simple
matter to create a HABTM for each of these new self-referential joins in
the model for R. Slick! Same effect though, partially connected node
graph.
BTW are the SQL statements behind HABTM reasonably optimized? I’m using
about 5 of these self-referential queries simultaneously against a
moderately large database and it is taking about 5-10 seconds to return.
I’m wondering what is the next step for either optimizing this query or
somehow caching results dynamically or perhaps pre-caching results in
advance (hopefully without losing generality).
BTW are the SQL statements behind HABTM reasonably optimized? I’m using
about 5 of these self-referential queries simultaneously against a
moderately large database and it is taking about 5-10 seconds to return.
I’m wondering what is the next step for either optimizing this query or
somehow caching results dynamically or perhaps pre-caching results in
advance (hopefully without losing generality).
I doubt they’d be overly optimised beyond the basics - it’d probably be
worth checking what turns up in the development log to see if you can
see anything obviously wrong.
And, as always, check your indices
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.