Abstract:Cardinality estimation is a core component of the query optimizer in database management systems (DBMS), and its accuracy directly affects the quality of execution plans. Although existing learning-based cardinality estimation methods outperform traditional methods in certain scenarios, they struggle to maintain consistently high accuracy on highly heterogeneous query workloads, where queries may differ significantly in the number of tables, join patterns, and predicates. Moreover, existing multi-model approaches lack a fine-grained mechanism for selecting models at the query level. Therefore, this study proposes a query routing-based cardinality estimation method, QRCE, whose core ideas include 1) constructing a heterogeneous and scalable Seq2Seq model space, integrating multiple sequence modeling architectures with different structural inductive biases to form a candidate model set; 2) building a gated mixture query router, GMQR, to achieve fine-grained model routing based on query semantics and enable adaptive decision-making for individual queries; 3) proposing a Q-error-based (1+ε)-approximate label strategy, transforming model selection into a supervised learning task, enabling the system to adaptively select the most suitable model based on the semantic features of each query. Experimental results on three benchmark datasets, STATS, JOB-light, and TPC-H, show that QRCE achieves significantly better overall and tail error performance than most baseline methods. Particularly on the structurally complex STATS dataset, QRCE reduces the Q99 error by approximately 53%, effectively avoiding long-tail catastrophic bias. On JOB-light, its Q99 is close to that of the best single model, while maintaining advantages at Q50/Q90/Q95. On TPC-H, the Q99 error is further reduced by about 16%. QRCE demonstrates stronger robustness and adaptability in long-tail queries and complex join scenarios.