The present invention discloses a method and an apparatus for querying data in cross-shard databases. The method includes: receiving a query request, where the query request includes a query condition; querying statistics information of respective shard databases in which two tables used in an association operation are located; sending, according to the statistics information and the query condition, a driving table query request to a shard database in which a driving table is located, and receiving a first query result set returned by the shard database in which the driving table is located, where one table of the two tables used in the association operation is the driving table, and the other table is a non-driving table; deduplicating association field values in the first query result set, and sending a result set delivery request and deduplicated association field values to a shard database in which the non-driving table is located; and sending a non-driving table query request to the shard database in which the non-driving table is located; and receiving a second query result set returned by the shard database in which the non-driving table is located. Efficiency of querying data in cross-shard databases is improved.
展开▼