Creating/Viewing Scrambles¶
A scramble is a special table used by VerdictDB to speed up query processing. The information about the created scrambles is stored in its metadata table and is used at query time.
Syntax for Creating Scrambles¶
CREATE SCRAMBLE [IF NOT EXISTS] new_schema.scrambled_table FROM original_schema.original_table [WHERE condition] [METHOD {UNIFORM|HASH}] [{HASHCOLUMN|ON} hash_column] [{SIZE|RATIO} percent=FLOAT] [BLOCKSIZE size=DECIMAL]
Note:
scrambled_tablemust be different fromoriginal_tableifnew_schemais the same asoriginal_schema.- The user requires write privilege for
newSchemaand read privilege fororiginalSchema.originalTable. METHODmust be eitherUNIFORMorHASH. AUNIFORMscramble is used forcount,sum,avg,maxandminqueries. AHASHscramble is used forcount distinctqueries.METHODisUNIFORMby default.- If a
HASHscramble is to be built,HASHCOLUMNorONmust be present.hash_columnindicates the column that will appear within the count-distinct function (e.g.,count(distinct hashcolumn)). SIZEorRATIO(percent = 1.0by default) defines the relative size of the scramble to its original table and must be a float value between 0.0 and 1.0 (e.g.,percent = 0.1will create a scramble with 10% size of the original table).- VerdictDB stores scrambles in a partitioned table and
BLOCKSIZE(size = 1,000,000 = 1Mby default) specifies the number of records in each partition. The maximum number of partitions for scrambles is 100 by default in VerdictDB. If the specifiedsizeresults in more than 100 partitions, it will be adjusted automatically. - The schema and table names can be quoted either using the double-quote (") or the backtick (`).
Syntax for Viewing Scrambles¶
SHOW SCRAMBLES;
This query will print the list of all scrambled tables that have been built.