I'm working on an "element inventory" application, that lists information about each element in my MODX installation. One of the things I want to do is, for each TV, show a count of all the published resources that have a TV value for that TV.
I'm using code that looks like this:
$collection = $modx->getCollectionGraph('modTemplateVarResource', '{"Resource":{}}', array('tmplvarid'=>$id, 'Resource.published'=>1));
This works, but it is taking forever. My snippet runs in about 2 seconds without it, about 9-10 seconds when this line of code is run.
Is there a faster way to get the answer I'm looking for? I chose getCollectionGraph because it lets me get the actual resource objects, which is the only way I know of to see if they are published or not. I could have used $tv->getMany to get the templateVarResource objects, but then I'd still need to get the related Resource object for each one to see if it is published.
Any thoughts?