Hi all,

When I do a search using torque, I am given a List of objects back, which I can iterate through at will.

These objects are linked with foreign key relationships to other objects, and so I can call getFoo() on each object in my result set, and torque will initiate a query and fetch the Foo object for me from the database. So far so good.

The problem I have in my case is that the Foo object is a status, and there are only a handful of possible statuses. What ends up happening is that the status table gets queried over and over again, one for each result in my original query. This takes time, and takes space.

Ideally what I'd like to have is torque be clever enough, when getStatus() is called, to say "hang on, I've already got a status with that key linked to this List or results, let me just use the one I have already got, and not query status again".

I am aware that torque supports caching, but I don't like caching as a solution, as I want the status object created within the same transaction as the original query.

Would it make sense for torque to be able to keep an optional index map for certain table relationships, and should this index map be present, torque first looks up the result in the index map before returning it to the client? And if not in the index map, an actual query is performed on the status table, the index map is updated, and the second time getStatus() is called, the object comes back from the index map, not the database. The nett effect is that if you have just 4 statuses in your complete result set, your status table will only ever be queried 4 times, and not once for every row in the original result set.

Does this kind of thing make sense?

Regards,
Graham
--


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to