The invention discloses a
database query optimization method and
system based on a general relation view. According to the method and the
system, a query instruction input by a user in a similar
natural language is received, and a
database table associated with target attributes and conditions is automatically analyzed; a weighted
graph model is constructed based on table relation topology, an improved path optimization
algorithm is adopted to dynamically generate a table connection sequence, and a path selection mechanism preferentially minimizes the calculation complexity of connection operation; for a cross-multi-table query scene, generating an optimal connection path through a
global model; finally, an optimization result is converted into a standard
database query statement to be executed. Compared with the prior art, the method and the
system have the advantages that the user operation threshold is obviously reduced, non-technical personnel can directly realize complex query through attribute names, the multi-table connection query efficiency is effectively improved, and the performance is close to that of native query in a large database environment; and a mainstream database system can be compatible through a
middleware framework, so that the method has wide applicability.