Brazhnyk,
This is true but not answering my question.
I am answering the question you are asking. If that answer is not acceptable for you, then there is some other question you are seeking an answer to that is not coming across correctly. This is something that you need to address before asking again, not I. I will rephrase to make sure that you understand as best as possible.
One Query call, per Snippet Call per URL Request. Its as simple as that, and that will always be the answer, period. The only time this is not the case is when the page Snippet is calling a Query multiple times because you or someone else coded it that way. It's all going to come down to your AJAX and how you perform the URL Request (which I stated above). If your "parent" page only makes one URL Request. The answer is 1. If it does more, the answer is "more". The techniques I pointed you to only make one such call.
But will it use only one DB query in one snippet call?
Your Query only issues one query call and this is all that is important (based on the code you have provided. There is
no way anyone on these forums can answer for yours or other Snippet, any other call, any other site code, without having the complete code, themselves. Other factors may include the browser (if it uses a technique that is nonstandard), the host (which may re-issue requests if it chooses), the caching method (which may actually reduce below 1 or increase it way above 1). Here's what we can tell you without knowing
anything else about your site code.
There is the call to get the requested URL (this may be more than one call). Then the call for every associated MODx tag. If the tag uses other tags, there may be calls for each one of those. If the tag is a Snippet and performs a query, then there is another there. If the Snippet calls another Snippet, hence another.call,etc.
The issue isn't how many calls there are (and never is). As a database applications programmer with over 16 years experience, the question is always how many
unnecessary calls there are. How much
unused information is coming from the database. It doesn't matter if there is only one call, if that call returns a huge amount of data that you don't need. That's why you can $q->select() and $q->limit() to begin with.
And may be you know some profiling tool for MODx...
I know of no such tools, but I don't use profiling. I've never had a need in 16 years (and probably never will, but I'm crazy). I know my code and use techniques that instantly tell me what is going on with my code if something goes awry. The other gurus may be aware of such and they might chime in.
[ed. note: fuzzicallogic last edited this post 14 years, 1 month ago.]