This is something what every developer want to know, how and what is going on when Drupal provide any result from query.
"How this query construct"
Well, it is not difficult, I will share some detail which gives you information about query construct and its parameters.
To debug any query, Drupal 8 provides addTag option. Before going in details first we should know about Tag and its usage.
Tags are simple string which identify query. In one query, there will be more than one tags. The main use is to alter hooks and take specific action based on specified tag. Tags should be all lower-case and it contains only letters numbers and underscore, and start with a letter. All rules of identifies applied to the Tag.
Coming to point, to debug any query in Drupal add debug in tags as below,
Where query is the query object, this line can be applicable with entity query, View query alter, search query alter and many other places.
If you like this post, please provide your comments.