Title: Analytics DB
Source: https://nodely.io/docs/solutions/clickhouse/

# Analytics DB

<a id="about-analytics-db"></a>

### About Analytics DB

Nodely DataWarehouse is based on open source ClickHouse DW.

<a id="interfaces"></a>

### Interfaces

DW interface is exposed by default as:

-   SQL REST API over HTTPS protocol at [https://dw2api.allo.info](https://dw2api.allo.info/)
-   [SQL Editor/playground](https://nodely.io/docs/solutions/clickhouse/sql-playground)
-   [Apache Superset](https://nodely.io/docs/solutions/clickhouse/superset) Self service business intelligence solution: [https://dw2bi.allo.info](https://dw2bi.allo.info/)

Custom endpoints/integrations include

-   [ODBC PowerBI DataSource](https://clickhouse.com/docs/en/integrations/powerbi)
-   Postgres or MySQL wire protocol endpoint

<a id="clickhouse-sql"></a>

## ClickHouse SQL

Clickhouse has powerful SQL language extensions and functions. It pays to learn about the join types, join orders, aggregations.

See: [ClickHouse SQL documentation](https://www.notion.so/ClickHouse-SQL-documentation-9a18c816cd3a4b97a5d4c0125e124014?pvs=21)

<a id="schema"></a>

## Schema

Allo analytics schema consists of several databases.

Each customer has access to dedicated scratch (no backup) database and common databases each corresponding to the named network - mainnet, voitestnet with custom ledger schema. Scratch database is available only on primary cluster. Failover does not have dedicated scratch database by default. Manual setup of table replication or backup schedule is possible with PS.

Caution

There are no NULL values in this schema. Most columns use ZERO VALUE to indicate NULL.

-   COALESCE will not behave as you expect
-   null dates are `1970-01-01 00:00:00`

\[[Allo.info](http://allo.info/) DW schema\]([https://www.notion.so/Allo-info-DW-schema-ee721bd35e8648b6980ecaa9b70329b7?pvs=21](https://www.notion.so/Allo-info-DW-schema-ee721bd35e8648b6980ecaa9b70329b7?pvs=21))

<a id="dictionaries"></a>

### Dictionaries

Dictionaries are in-memory maps that can quickly map between a Uint64 ID and a named value.

Dictionaries periodically refresh data from their source. **Refreshes are atomic,** no duplicated entries are to be expected.

Dictionaries have dict\_ as a prefix in their names and are grouped in databases with \_mem suffix:

-   mainnet\_mem
-   testnet\_mem
-   betanet\_mem

Each dictionary has corresponding `JOIN Table` that can be used for classical (yet instant) joins .

All tables with no dict\_ prefix in \*\_mem databases can be used for instant joins.

[Dictionaries](https://www.notion.so/Dictionaries-32fa32e386f34c7b8879005fae9a35aa?pvs=21)

<a id="tables"></a>

### Tables

All native (non dictionary based) tables are append only and can contain duplicated rows. Deduplication is eventual and nondeterministic.

To see dedupilcated view one must use `FINAL` keyword or user argMax functions to select only relevant rows.

💡 All end-user accounts have \`FINAL\` keyword added by default to all queries.

<a id="working-with-external-data"></a>

### Working with external data

[Working with external data](https://www.notion.so/Working-with-external-data-e80ccc4d1d614ea38c5b44b40269f247?pvs=21)

<a id="default-settings-for-end-users"></a>

### Default settings for end-users

| Setting | Value | Description |
| --- | --- | --- |
| optimize\_move\_to\_prewhere\_if\_final | 1 | Optimize deduplication by applying WHERE filters before dedup phase. |
| final | 1 | Automatically applies [https://clickhouse.com/docs/en/sql-reference/statements/select/from#final-modifier](https://clickhouse.com/docs/en/sql-reference/statements/select/from#final-modifier) modifier to all tables in a query |
| union\_default\_mode | DISTINCT | Default union behaviour when not specified |
| optimize\_rewrite\_aggregate\_function\_with\_if | 1 |  |
| allow\_experimental\_analyzer | 0 |  |
| optimize\_syntax\_fuse\_functions | 1 |  |
|  |  |  |

<a id="exposing-queries-as-api"></a>

### Exposing queries as API

[Exposing queries as API](https://www.notion.so/Exposing-queries-as-API-d9d98c344a7641948c3dc94d426ac34f?pvs=21)

[SQL Playground](https://www.notion.so/SQL-Playground-fc686ce4d01e47c2886fff051f79a319?pvs=21)

[Allo Algorand BI](https://www.notion.so/Allo-Algorand-BI-d11cbf2625b04e0eb3931013b20e6ec2?pvs=21)

[ODBC DW Access](https://www.notion.so/ODBC-DW-Access-65497c183ff14b5aae234ca0f983976e?pvs=21)
