You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Finally, I want to calculate SUM and BITXOR of CRC32RES at the same time:
mysql>SELECT->COUNT(1) as CNT, SUM(CRC32RES) as SUM_CHECKSUM, BIT_XOR(CRC32RES) as BIT_XOR_CHECKSUM
->FROM-> (SELECT-> CAST(CRC32(CONCAT_WS(',', `s_i_id`, `s_w_id`, CONCAT(ISNULL(`s_i_id`), ISNULL(`s_w_id`))))AS UNSIGNED) as CRC32RES
->FROM`test`.`tbl`) as CRC32LIST;
+-----+--------------+------------------+
| CNT | SUM_CHECKSUM | BIT_XOR_CHECKSUM |
+-----+--------------+------------------+
| 3 | 9646058107 | 3199522115 |
+-----+--------------+------------------+1 row inset (0.01 sec)
This is OK when the table is very small. However, when the each line of the table is very large, there will be double delay than only use one aggregation.
Yes, when the expression appears more than once, the planner should be extract common expression into a Projection operator. In this case, the planner should not inline the expressions. @XuHuaiyu I know TiFlash can automatically reuse the result of duplicate expressions, currently does TiKV do the same optimization internally?
Feature Request
Is your feature request related to a problem? Please describe:
Suppose I have a table like this:
Then calculate a value for each line according to the specified function:
Finally, I want to calculate
SUM
andBITXOR
ofCRC32RES
at the same time:This is OK when the table is very small. However, when the each line of the table is very large, there will be double delay than only use one aggregation.
See the explain of this SQL:
It seems that this function is calculated twice, which costs double time.
Describe the feature you'd like:
Can this be optimized?
Describe alternatives you've considered:
Teachability, Documentation, Adoption, Migration Strategy:
The text was updated successfully, but these errors were encountered: