设想如下:
Master机器利用FEDERATED引擎映射4台分服务器上同类型的表。在Master机器上用如下语句:
select XXX from FEDERATED_1 where XXX
union all
select XXX from FEDERATED_2 where XXX
union all
select XXX from FEDERATED_3 where XXX
union all
select XXX from FEDERATED_4 where XXX想要了解的是,上面这句sql是在分服务器_1执行完再到分服务器_2执行,以此类推?还是各台分服务器并发执行相应的select,然后各自返回后union all?顺道问下FEDERATED引擎稳定性如何?会不会有莫名其妙的状况出现?(我目前没发现,各位有生产环境的经验最好)

解决方案 »

  1.   

    这个可能牵扯到union all实现机制,有哪位牛人能指点一下?即,union all 前后的 select 语句是否并发执行?
      

  2.   

    各台分服务器并发执行相应的select,然后各自返回后union all
      

  3.   

    MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.htmlWhen executing queries and statements on a FEDERATED table on the local server, the operations that would normally insert, update or delete information from a local data file are instead sent to the remote server for execution, where they update the data file on the remote server or return matching rows from the remote server. The basic structure of a FEDERATED table setup is shown in Figure 13.2, “FEDERATED table structure”. Figure 13.2. FEDERATED table structure
    When a client issues an SQL statement that refers to a FEDERATED table, the flow of information between the local server (where the SQL statement is executed) and the remote server (where the data is physically stored) is as follows: The storage engine looks through each column that the FEDERATED table has and constructs an appropriate SQL statement that refers to the remote table. The statement is sent to the remote server using the MySQL client API. The remote server processes the statement and the local server retrieves any result that the statement produces (an affected-rows count or a result set). If the statement produces a result set, each column is converted to internal storage engine format that the FEDERATED engine expects and can use to display the result to the client that issued the original statement.