Aggregate Functions • WAIT_FOR_EXECUTED_GTID_SET( gtid_set [,  timeout ]) • WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS( gtid_set [,  timeout ][, channel ]) 12.20.1 Aggregate Function Descriptions 12.20 Aggregate Functions Wait until the server has applied all of the transactions whose global transaction identifiers are contained in  gtid_set ; that is, until the condition GTID_SUBSET( gtid_subset ,  @@GLOBAL.gtid_executed ) holds. See Section 17.1.3.1, “GTID Format and Storage”  for a definition of GTID sets. If a timeout is specified, and  timeout  seconds elapse before all of the transactions in the GTID set have been applied, the function stops waiting.  timeout  is optional, and the default timeout is 0 seconds, in which case the function always waits until all of the transactions in the GTID set have been applied. WAIT_FOR_EXECUTED_GTID_SET()  monitors all the GTIDs that are applied on the server, including transactions that arrive from all replication channels and user clients. It does not take into account whether replication channels have been started or stopped. For more information, see Section 17.1.3, “Replication with Global Transaction Identifiers” . GTID sets used with this function are represented as strings and so must be quoted as shown in the following example: mysql>  SELECT WAIT_FOR_EXECUTED_GTID_SET(’3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5’); -> 0 For a syntax description for GTID sets, see Section 17.1.3.1, “GTID Format and Storage” . For  WAIT_FOR_EXECUTED_GTID_SET() , the return value is the state of the query, where 0 represents success, and 1 represents timeout. Any other failures generate an error. gtid_mode  cannot be changed to OFF while any client is using this function to wait for GTIDs to be applied. WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS()  is deprecated. Use WAIT_FOR_EXECUTED_GTID_SET()  instead, which works regardless of the replication channel or user client through which the specified transactions arrive on the server. Aggregate functions operate on sets of values. They are often used with a  GROUP BY  clause to group values into subsets. This section describes most aggregate functions. For information about aggregate functions that operate on geometry values, see Section 12.17.12, “Spatial Aggregate Functions” . This section describes aggregate functions that operate on sets of values. They are often used with a GROUP BY  clause to group values into subsets. Table 12.25 Aggregate Functions Name Description AVG() Return the average value of the argument BIT_AND() Return bitwise AND BIT_OR() Return bitwise OR BIT_XOR() Return bitwise XOR COUNT() Return a count of the number of rows returned 2394