> One thing puzzles me. Why does the same query take different execution time > in GUI and PHP ? > In GUI - 2.5-3sec, in PHP - 8-10sec.
There are too many factors that influence execution time (bandwidth, result size, etc.), so you will need to provide us with more information, such as a minimized code example that demonstrates your observations. Instead of providing your original data, you could e.g. write a little self-contained XQuery expression that creates data of the same size.