ClickHouse/docs/en/sql-reference/dictionaries/external-dictionaries
Azat Khuzhin 064f901ea8 Add ability to preallocate hashtables for hashed/sparsehashed dictionaries
preallocation can be used only when we know number of rows, and for this
we need:
- source clickhouse
- no filtering (i.e. lack of <where>), since filtering can filter
  too much rows and eventually it may allocate memory that will
  never be used.

For sparse_hash the difference is quite significant, preallocated
sparse_hash hashtable allocates ~33% faster (7.5 seconds vs 5 seconds
for insert, and the difference is more significant for higher number of
elements):

    $ ninja bench-sparse_hash-run
    [1/1] cd /src/ch/hashtable-bench/.cmake && ...ch/hashtable-bench/.cmake/bench-sparse_hash
    sparse_hash/insert: 7.574 <!--
    sparse_hash/find  : 2.14426
    sparse_hash/maxrss: 174MiB
    sparse_hash/time:   9710.51 msec (user+sys)

    $ time ninja bench-sparse_hash-preallocate-run
    [1/1] cd /src/ch/hashtable-bench/.cmake && ...-bench/.cmake/bench-sparse_hash-preallocate
    sparse_hash/insert: 5.0522 <!--
    sparse_hash/find  : 2.14024
    sparse_hash/maxrss: 174MiB
    sparse_hash/time:   7192.06 msec (user+sys)

P.S. the difference for sparse_hashed dictionary with 4e9 elements
(uint64, uint16) is ~18% (4975.905 vs 4103.569 sec)

v2: do not reallocate the dictionary from the progress callback
    Since this will access hashtable in parallel.
v3: drop PREALLOCATE() and do this only for source=clickhouse and empty
    <where>
2020-10-09 22:28:14 +03:00
..
external-dicts-dict-hierarchical.md [docs] split aggregate function and system table references (#11742) 2020-06-18 11:24:31 +03:00
external-dicts-dict-layout.md Add ability to preallocate hashtables for hashed/sparsehashed dictionaries 2020-10-09 22:28:14 +03:00
external-dicts-dict-lifetime.md Update external-dicts-dict-lifetime.md (#12657) 2020-07-22 11:26:04 +03:00
external-dicts-dict-sources.md Improved the description of connecting to MS SQL Server by ODBC. 2020-09-15 11:26:57 -07:00
external-dicts-dict-structure.md [docs] split aggregate function and system table references (#11742) 2020-06-18 11:24:31 +03:00
external-dicts-dict.md [docs] split various kinds of CREATE queries into separate articles (#12328) 2020-07-09 18:10:35 +03:00
external-dicts.md [docs] split various kinds of CREATE queries into separate articles (#12328) 2020-07-09 18:10:35 +03:00
index.md [docs] replace underscores with hyphens (#10606) 2020-04-30 21:19:18 +03:00