Twig pattern matching is a core operation in XML query processing because it is how all the occurrences
of a twig pattern in an XML document are found. In the past decade, many algorithms have been proposed
to perform twig pattern matching. They rely on labelling schemes to determine relationships between
elements corresponding to query nodes in constant time. In this paper, a new algorithm TwigStackPrime is
proposed, which is an improvement to TwigStack (Bruno et al., 2002). To reduce the memory consumption and
computation overhead of twig pattern matching algorithms when Parent-Child (P-C) edges are involved, TwigStackPrime
efficiently filters out a tremendous number of irrelevant elements by introducing a new labelling
scheme, called Child Prime Label (CPL). Extensive performance studies on various real-world and artificial
datasets were conducted to demonstrate the significant improvement of CPL over the previous indexing and
querying techniques. The experimental results show that the new technique has a superior performance to the
previous approaches