Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEO updates, cross-links #131

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions content/en/altinity-kb-queries-and-syntax/projections-examples.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
---
title: "Projections"
linkTitle: "Projections"
title: "ClickHouse® Projections"
linkTitle: "ClickHouse Projections"
description: >
Projections
Using this ClickHouse feature to optimize queries
keywords:
- clickhouse projections
- clickhouse projection vs materialized view
---

Projections in ClickHouse act as inner tables within a main table, functioning as a mechanism to optimize queries by using these inner tables when only specific columns are needed. Essentially, a projection is similar to a Materialized View with an AggregatingMergeTree engine, designed to be automatically populated with relevant data.
Projections in ClickHouse act as inner tables within a main table, functioning as a mechanism to optimize queries by using these inner tables when only specific columns are needed. Essentially, a projection is similar to a [Materialized View](/altinity-kb-schema-design/materialized-views/) with an [AggregatingMergeTree engine](/engines/mergetree-table-engine-family/aggregatingmergetree/), designed to be automatically populated with relevant data.

However, too many projections can lead to excess storage, much like overusing Materialized Views. Projections share the same lifecycle as the main table, meaning they are automatically backfilled and don’t require query rewrites, which is particularly advantageous when integrating with BI tools.

Expand All @@ -20,7 +23,7 @@ Projection parts are stored within the main table parts, and their merges occur
* Blog video https://clickhouse.com/videos/how-to-a-clickhouse-query-using-projections


## Why is a projection not used?
## Why is a ClickHouse projection not used?

A query analyzer should have a reason for using projection.

Expand Down Expand Up @@ -74,11 +77,8 @@ Expression ((Project names + Projection))

What happens in the case of non-trivial background merges in ReplacingMergeTree, AggregatingMergeTree and similar, and OPTIMIZE table DEDUPLICATE queries?

Before version 24.8, projections became out of sync with the main data.

Since version 24.8, it is controlled by a new table-level setting:

[deduplicate_merge_projection_mode](https://clickhouse.com/docs/en/operations/settings/merge-tree-settings#deduplicate_merge_projection_mode) = 'throw'/'drop'/'rebuild'
* Before version 24.8, projections became out of sync with the main data.
* Since version 24.8, it is controlled by a new table-level setting:<br/>[deduplicate_merge_projection_mode](https://clickhouse.com/docs/en/operations/settings/merge-tree-settings#deduplicate_merge_projection_mode) = `throw`/`drop`/`rebuild`

However, projection usage is still disabled for FINAL queries. So, you have to use OPTIMIZE FINAL or SELECT ...GROUP BY instead of FINAL for fighting duplicates between parts

Expand Down Expand Up @@ -165,7 +165,7 @@ where create_table_query ilike '%projection%'

## Examples

### Aggregating projections
### Aggregating ClickHouse projections

```sql
create table z(Browser String, Country UInt8, F Float64)
Expand Down Expand Up @@ -224,7 +224,7 @@ Elapsed: 0.005 sec. Processed 22.43 thousand rows

### Emulation of an inverted index using orderby projection

You can create an `orderby projection` and include all columns of a table, but if a table is very wide it will double of stored data. This example demonstrate a trick, we create an `orderby projection` and include primary key columns and the target column and sort by the target column. This allows using subquery to find [primary key values](../../engines/mergetree-table-engine-family/pick-keys/) and after that to query the table using the primary key.
You can create an `orderby projection` and include all columns of a table, but if a table is very wide it will double the amount of stored data. This example demonstrate a trick, we create an `orderby projection` and include primary key columns and the target column and sort by the target column. This allows using subquery to find [primary key values](../../engines/mergetree-table-engine-family/pick-keys/) and after that to query the table using the primary key.

```sql
CREATE TABLE test_a
Expand Down
7 changes: 5 additions & 2 deletions content/en/altinity-kb-queries-and-syntax/ttl/modify-ttl.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
---
title: "MODIFY (ADD) TTL"
title: "MODIFY (ADD) TTL in ClickHouse®"
linkTitle: "MODIFY (ADD) TTL"
weight: 100
description: >-
What happens during a MODIFY or ADD TTL query.
What happens during a MODIFY or ADD TTL query
keywords:
- clickhouse modify ttl
- clickhouse alter table ttl
---

*For a general overview of TTL, see the article [Putting Things Where They Belong Using New TTL Moves](https://altinity.com/blog/2020-3-23-putting-things-where-they-belong-using-new-ttl-moves).*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
title: "ClickHouse® Monitoring"
linkTitle: "ClickHouse® Monitoring"
description: >
ClickHouse® Monitoring
Tracking potential issues in your cluster before they cause a critical error
keywords:
- clickhouse monitoring
- clickhouse metrics
---

## ClickHouse® Monitoring

Monitoring helps to track potential issues in your cluster before they cause a critical error.

What to read / watch on subject:
* Altinity webinar "ClickHouse Monitoring 101: What to monitor and how". [recording](https://www.youtube.com/watch?v=W9KlehhgwLw), [slides](https://www.slideshare.net/Altinity/clickhouse-monitoring-101-what-to-monitor-and-how)
* docs https://clickhouse.com/docs/en/operations/monitoring/
What to read / watch on the subject:
* Altinity webinar "ClickHouse Monitoring 101: What to monitor and how". [Watch the video](https://www.youtube.com/watch?v=W9KlehhgwLw) or [download the slides](https://www.slideshare.net/Altinity/clickhouse-monitoring-101-what-to-monitor-and-how).
* [The ClickHouse docs](https://clickhouse.com/docs/en/operations/monitoring/)

## What should be monitored

Expand All @@ -38,7 +37,7 @@ The following metrics should be collected / monitored
* [See separate article](../altinity-kb-zookeeper/zookeeper-monitoring/)


## Monitoring tools
## ClickHouse monitoring tools

### Prometheus (embedded exporter) + Grafana

Expand Down Expand Up @@ -99,9 +98,9 @@ The following metrics should be collected / monitored
* site24x7 https://www.site24x7.com/plugins/clickhouse-monitoring.html
* Acceldata Pulse https://www.acceldata.io/blog/acceldata-pulse-for-clickhouse-monitoring

### "Build your own" monitoring
### "Build your own" ClickHouse monitoring

ClickHouse allow to access lot of internals using system tables. The main tables to access monitoring data are:
ClickHouse allows to access lots of internals using system tables. The main tables to access monitoring data are:
* system.metrics
* system.asynchronous_metrics
* system.events
Expand Down Expand Up @@ -310,13 +309,13 @@ The following queries are recommended to be included in monitoring:
* `SELECT * FROM system.mutations`
* This is the source of information on the speed and progress of currently executed merges.

## Logs monitoring
## Monitoring ClickHouse logs

ClickHouse logs can be another important source of information. There are 2 logs enabled by default
[ClickHouse logs](/altinity-kb-setup-and-maintenance/logging/) can be another important source of information. There are 2 logs enabled by default
* /var/log/clickhouse-server/clickhouse-server.err.log (error & warning, you may want to keep an eye on that or send it to some monitoring system)
* /var/log/clickhouse-server/clickhouse-server.log (trace logs, very detailed, useful for debugging, usually too verbose to monitor).

You can additionally enable system.text_log table to have an access to the logs from clickhouse sql queries (ensure that you will not expose some information to the users which should not see it).
You can additionally enable system.text_log table to have an access to the logs from clickhouse sql queries (ensure that you will not expose some information to the users who should not see it).
```
$ cat /etc/clickhouse-server/config.d/text_log.xml
<yandex>
Expand Down