In MySQL, you can define a procedure in C++ that can access and
modify the data in a query before it is sent to the client. The
modification can be done on a row-by-row or GROUP
BY
level.
We have created an example procedure to show you what can be done.
Additionally, we recommend that you take a look at
mylua
. With this you can use the LUA language
to load a procedure at runtime into mysqld.
analyse([
max_elements
,[max_memory
]])
This procedure is defined in the
sql/sql_analyse.cc
. This examines the
result from your query and returns an analysis of the results:
-
max_elements
(default 256) is the maximum number of distinct valuesanalyse
does notice per column. This is used byanalyse
to check whether the optimal data type should be of typeENUM
. -
max_memory
(default 8192) is the maximum amount of memory thatanalyse
should allocate per column while trying to find all distinct values.
SELECT ... FROM ... WHERE ... PROCEDURE ANALYSE([max_elements
,[max_memory
]])