Greetings community,-

Apologies in advance for the lack of brevity here, and my gratitude in 
advance for your attention.

I have been attempting to get a reasonably shallow depth rcte tree model to 
work with some many-to-many associations for a few months now, and am 
failing to attain any reasonable performance.

The backend is a PostgreSQL database, and the application is running in 
JRuby using the jdbc-postgres adapter.  I am using Sequel version 4.4.

It is certainly possibly, perhaps likely, that my design is poor or my 
model definitions are erroneous.  I'm open-minded about alternative 
suggestions.

Each primary tree node model instance uses the after_initialize hook to 
perform a simple looped function on the respective association members.

So far I have two main problems.

1) A node instance executes the after_initialize hook every time a node 
instance is fetched, even if it has already been fetched once already. 
 This is unfortunate, because I would like the program to only have to run 
this functionality once for each individual node, no matter how often the 
program retrieves that node from the datasource.

Unfortunately, I cannot seem to reliably get rcte tree model instances to 
keep themselves in a global in-memory cache (let alone a memcached 
instance), and from it be subsequently retrieved.  It seems that only some 
instances are loaded into the cache, and then only the main model instance, 
with none of its associations.

2) The second problem arises whenever the association members of the tree 
node model instance is accessed -- the following query is ran for each 
association access:

SELECT "album".* FROM "album" INNER JOIN "artist_to_album" ON 
(("artist_to_album"."album_id" = "album"."id") AND 
("artist_to_album"."artist_id" = 1))

I would like to have each association load eagerly onto each node model 
instance so that no query is ran when accessing the node's association 
members.

I think that I understand that this may not be possible in conjunction with 
the rcte_tree plugin for Sequel.  For some reason I was under the 
impression that association eager loading was working for normal 
associations, just not for the tree associations.  (Perhaps until recently?)

I have tried both using, and not using, the :caching and 
:tactical_eager_loading plugins on the album module.  I've tried using and 
not using those plugins on all involved model definitions.  Nothing seems 
to make a difference.

Is it indeed still the case that the rcte tree plugin is simply 
incompatible with these plugins entirely?  If so, I suppose I will have to 
come up with another approach to obtaining a traversable tree model, or 
something similar.

I have considered using Neo4j instead of PostgreSQL and Sequel.

Thanks again for your consideration.

-Nels

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to