segment/scan/pending metric


I wanted to get better understanding of how a query gets executed on historical and indexer peons. I’ve enabled metics and have noticed that sometimes ‘segment/scan/pending’ value increases rapidly and query timings increase as well. Not sure how segments are queued and picked up by threads processing a query. Aren’t segments shared across multiple query processing threads? Do segment queue up because individual segment processing time ‘query/segment/time’ are high for some queries which have lots of filters?
Could someone point me to documentation which explains how queries work?