ClickHouse® dictionaries
Dictionaries in ClickHouse® are mappings of key-value pairs that are fully or partially stored in the ClickHouse® server memory.
To access dictionary data, you need to use dedicated functions
The main advantage of dictionaries is that you can get results faster compared to JOIN operations. Opt for dictionaries if you frequently query references to get values by a key.
As their data sources, dictionaries can use ClickHouse® internal dictionaries
Internal dictionaries
Managed Service for ClickHouse® contains an embedded geobase dictionary and functions to work with it. With this dictionary, you can:
- Get the name of a region in the required language by the region ID.
- Get the ID of a city, district, state/province, country, and continent by the region ID.
- Check whether one region is part of another.
- Get a chain of parent regions.
For more about the functions for working with internal dictionaries, see this ClickHouse® guide
If the built-in geobase does not fit your purpose, you can add a custom geobase to ClickHouse®.
External dictionaries
External dictionaries can use HTTP(s) resources and other DBMS's, such as MySQL®, ClickHouse®, Yandex StoreDoc, and PostgreSQL, as data sources.
Depending on the dictionary settings, ClickHouse® fully or partially stores dictionaries in RAM, updates them on a regular basis, and dynamically loads the missing values.
To learn how to connect and configure a dictionary using Yandex Managed Service for ClickHouse®, see Connecting external dictionaries.
Use cases
ClickHouse® is a registered trademark of ClickHouse, Inc