DuckDB 1.4.0发版说明中提到
To encrypt data, DuckDB can use either the built-in mbedtls library or the OpenSSL library from the httpfs extension. Note that the OpenSSL versions are much faster due to hardware acceleration, so make sure to LOAD httpfs for good encryption performance.
同样的加密脚本,
load tpch;
call dbgen(sf=1);
ATTACH 'ENC_NO' as ENC_NO;
use enc_no;
call dbgen(sf=1);
ATTACH 'ENC_GCM' as ENC_GCM (ENCRYPTION_KEY 'asdf', ENCRYPTION_CIPHER 'GCM');
use enc_gcm;
call dbgen(sf=1);
ATTACH 'ENC_CTR' as ENC_CTR (ENCRYPTION_KEY 'asdf', ENCRYPTION_CIPHER 'CTR');
use enc_ctr;
call dbgen(sf=1);
在Windows和Linux分别不load和load httpfs测试。
Windows 11
C:\d>duckdb140
DuckDB v1.4.0 (Andium) b8a06e4a22
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D .read ENCRY.txt
100% ▕██████████████████████████████████████▏ (00:00:02.43 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:08.71 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:10.95 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:08.73 elapsed)
注意需要退出后重新运行duckdb,否则会报IO Error:Cannot open file "ENC_NO": Permission denied错误。
C:\d>duckdb140
DuckDB v1.4.0 (Andium) b8a06e4a22
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D load httpfs;
D .read ENCRY.txt
100% ▕██████████████████████████████████████▏ (00:00:02.30 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:08.10 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:07.59 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:07.64 elapsed)
D .exit
Linux
DuckDB v1.4.0 (Andium) b8a06e4a22
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D .read /par/ENCRY.txt
100% ▕██████████████████████████████████████▏ (00:00:03.45 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:08.71 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:09.50 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:08.66 elapsed)
D .exit
root@DESKTOP-59T6U68:/par# ./duckdb140
DuckDB v1.4.0 (Andium) b8a06e4a22
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D install httpfs;
100% ▕██████████████████████████████████████▏ (00:00:15.77 elapsed)
D .read /par/ENCRY.txt
100% ▕██████████████████████████████████████▏ (00:00:02.85 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:07.76 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:09.09 elapsed)
100% ▕██████████████████████████████████████▏ (00:00:08.55 elapsed)
可见LOAD httpfs 确实提高了DuckDB加密的性能,从零点几秒到1秒不等。Windows没有wsl的IO速度慢的影响,区别更明显。


被折叠的 条评论
为什么被折叠?



