The invention discloses an invitation code promotion level query system based on a B tree and a forest. The method comprises the following specific steps: 1, constructing all natural users as root nodes of a tree B in a forest, 2, constructing child nodes of the tree B and completing tree construction, 3, storing the B tree and a forest data model, 4, monitoring changes of database users by a monitoring thread and dynamically updating the tree and the forest, 5, carrying out related query according to the constructed B tree and forest model, and 6, performing persistence of the tree B and theforest data model. Through the query system, the farm game users are ranked, so that the problem of low efficiency in a massive data environment in hierarchical query is effectively solved, meanwhile,a model based on a B tree and a forest is provided, and tree nodes are self-defined, so that the system not only meets the requirement of improving the efficiency of common hierarchical query, but also can realize more conditional queries.