mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 08:52:06 +00:00
2d2bc052e1
* Typo fix. * Links fix. * Fixed links in docs. * More fixes. * docs/en: cleaning some files * docs/en: cleaning data_types * docs/en: cleaning database_engines * docs/en: cleaning development * docs/en: cleaning getting_started * docs/en: cleaning interfaces * docs/en: cleaning operations * docs/en: cleaning query_lamguage * docs/en: cleaning en * docs/ru: cleaning data_types * docs/ru: cleaning index * docs/ru: cleaning database_engines * docs/ru: cleaning development * docs/ru: cleaning general * docs/ru: cleaning getting_started * docs/ru: cleaning interfaces * docs/ru: cleaning operations * docs/ru: cleaning query_language * docs: cleaning interfaces/http * Update docs/en/data_types/array.md decorated ``` Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/getting_started/example_datasets/nyc_taxi.md fixed typo Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/getting_started/example_datasets/ontime.md fixed typo Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/interfaces/formats.md fixed error Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/table_engines/custom_partitioning_key.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/utils/clickhouse-local.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/dicts/external_dicts_dict_sources.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/utils/clickhouse-local.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/json_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/json_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/other_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/other_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/date_time_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/table_engines/jdbc.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * docs: fixed error * docs: fixed error
87 lines
4.0 KiB
Markdown
87 lines
4.0 KiB
Markdown
# StripeLog
|
|
|
|
This engine belongs to the family of log engines. See the common properties of log engines and their differences in the [Log Engine Family](log_family.md) article.
|
|
|
|
Use this engine in scenarios when you need to write many tables with a small amount of data (less than 1 million rows).
|
|
|
|
## Creating a Table {#table_engines-stripelog-creating-a-table}
|
|
|
|
```sql
|
|
CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster]
|
|
(
|
|
column1_name [type1] [DEFAULT|MATERIALIZED|ALIAS expr1],
|
|
column2_name [type2] [DEFAULT|MATERIALIZED|ALIAS expr2],
|
|
...
|
|
) ENGINE = StripeLog
|
|
```
|
|
|
|
See the detailed description of the [CREATE TABLE](../../query_language/create.md#create-table-query) query.
|
|
|
|
## Writing the Data {#table_engines-stripelog-writing-the-data}
|
|
|
|
The `StripeLog` engine stores all the columns in one file. For each `INSERT` query, ClickHouse appends the data block to the end of a table file, writing columns one by one.
|
|
|
|
For each table ClickHouse writes the files:
|
|
|
|
- `data.bin` — Data file.
|
|
- `index.mrk` — File with marks. Marks contain offsets for each column of each data block inserted.
|
|
|
|
The `StripeLog` engine does not support the `ALTER UPDATE` and `ALTER DELETE` operations.
|
|
|
|
## Reading the Data {#table_engines-stripelog-reading-the-data}
|
|
|
|
The file with marks allows ClickHouse to parallelize the reading of data. This means that a `SELECT` query returns rows in an unpredictable order. Use the `ORDER BY` clause to sort rows.
|
|
|
|
## Example of Use {#table_engines-stripelog-example-of-use}
|
|
|
|
Creating a table:
|
|
|
|
```sql
|
|
CREATE TABLE stripe_log_table
|
|
(
|
|
timestamp DateTime,
|
|
message_type String,
|
|
message String
|
|
)
|
|
ENGINE = StripeLog
|
|
```
|
|
|
|
Inserting data:
|
|
|
|
```sql
|
|
INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The first regular message')
|
|
INSERT INTO stripe_log_table VALUES (now(),'REGULAR','The second regular message'),(now(),'WARNING','The first warning message')
|
|
```
|
|
|
|
We used two `INSERT` queries to create two data blocks inside the `data.bin` file.
|
|
|
|
ClickHouse uses multiple threads when selecting data. Each thread reads a separate data block and returns resulting rows independently as it finishes. As a result, the order of blocks of rows in the output does not match the order of the same blocks in the input in most cases. For example:
|
|
|
|
```sql
|
|
SELECT * FROM stripe_log_table
|
|
```
|
|
```text
|
|
┌───────────timestamp─┬─message_type─┬─message────────────────────┐
|
|
│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │
|
|
│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │
|
|
└─────────────────────┴──────────────┴────────────────────────────┘
|
|
┌───────────timestamp─┬─message_type─┬─message───────────────────┐
|
|
│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │
|
|
└─────────────────────┴──────────────┴───────────────────────────┘
|
|
```
|
|
|
|
Sorting the results (ascending order by default):
|
|
|
|
```sql
|
|
SELECT * FROM stripe_log_table ORDER BY timestamp
|
|
```
|
|
```text
|
|
┌───────────timestamp─┬─message_type─┬─message────────────────────┐
|
|
│ 2019-01-18 14:23:43 │ REGULAR │ The first regular message │
|
|
│ 2019-01-18 14:27:32 │ REGULAR │ The second regular message │
|
|
│ 2019-01-18 14:34:53 │ WARNING │ The first warning message │
|
|
└─────────────────────┴──────────────┴────────────────────────────┘
|
|
```
|
|
|
|
[Original article](https://clickhouse.yandex/docs/en/operations/table_engines/stripelog/) <!--hide-->
|