polardbx-sql icon indicating copy to clipboard operation
polardbx-sql copied to clipboard

support benchmark function

Open tuichenchuxin opened this issue 10 months ago • 0 comments
trafficstars

我想支持下 benchmark function,例如

SELECT BENCHMARK(30000, (SELECT id from test limit 1));

SELECT BENCHMARK(100, (AES_ENCRYPT('HELLO', 'WORLD')))

我发现了BenchmarkVectorizedExpression 这个类,但是 debug 的时候,发现children[1] 的(SELECT id from test limit 1) 被解析成了 InputRefVectorizedExpression ,这样实际计算的时候走的如下方法,不会真正运行多次,在 if 判断处就返回了。

    public void eval(EvaluationContext ctx) {
        if (outputIndex != inputIndex) {
            MutableChunk chunk = ctx.getPreAllocatedChunk();
            boolean isSelectionInUse = chunk.isSelectionInUse();
            int[] selection = chunk.selection();
            chunk.slotIn(outputIndex).copySelected(isSelectionInUse, selection, chunk.batchSize(),
                chunk.slotIn(inputIndex));
        }
    }
    ```
    
    另外运行 SELECT BENCHMARK(100, (AES_ENCRYPT('HELLO', 'WORLD'))) 提示不支持 BENCHMARK 方法。
    
    社区大佬们可以提示下支持的思路么,我非常愿意提交这个 pr 来支持。

tuichenchuxin avatar Jan 07 '25 02:01 tuichenchuxin