2020-04-03 13:23:32 +00:00
---
toc_priority: 32
toc_title: StripeLog
---
2022-06-02 10:55:18 +00:00
# Stripelog
2019-02-04 14:52:31 +00:00
2020-07-09 12:11:15 +00:00
This engine belongs to the family of log engines. See the common properties of log engines and their differences in the [Log Engine Family ](../../../engines/table-engines/log-family/index.md ) article.
2019-02-04 14:52:31 +00:00
2019-02-11 13:32:00 +00:00
Use this engine in scenarios when you need to write many tables with a small amount of data (less than 1 million rows).
2019-02-04 14:52:31 +00:00
2020-03-22 09:14:59 +00:00
## Creating a Table {#table_engines-stripelog-creating-a-table}
2019-02-04 14:52:31 +00:00
2020-03-20 10:10:48 +00:00
``` sql
2019-02-04 14:52:31 +00:00
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
```
2020-07-09 15:10:35 +00:00
See the detailed description of the [CREATE TABLE ](../../../sql-reference/statements/create/table.md#create-table-query ) query.
2019-02-04 14:52:31 +00:00
2020-03-22 09:14:59 +00:00
## Writing the Data {#table_engines-stripelog-writing-the-data}
2019-02-04 14:52:31 +00:00
2019-02-11 13:32:00 +00:00
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.
2019-02-04 14:52:31 +00:00
2019-02-11 13:32:00 +00:00
For each table ClickHouse writes the files:
2019-02-04 14:52:31 +00:00
2020-03-21 04:11:51 +00:00
- `data.bin` — Data file.
- `index.mrk` — File with marks. Marks contain offsets for each column of each data block inserted.
2019-02-04 14:52:31 +00:00
The `StripeLog` engine does not support the `ALTER UPDATE` and `ALTER DELETE` operations.
2020-03-22 09:14:59 +00:00
## Reading the Data {#table_engines-stripelog-reading-the-data}
2019-02-04 14:52:31 +00:00
2019-02-11 13:32:00 +00:00
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.
2019-02-04 14:52:31 +00:00
2020-04-30 18:19:18 +00:00
## Example of Use {#table_engines-stripelog-example-of-use}
2019-02-04 14:52:31 +00:00
Creating a table:
2020-03-20 10:10:48 +00:00
``` sql
2019-02-04 14:52:31 +00:00
CREATE TABLE stripe_log_table
(
timestamp DateTime,
message_type String,
message String
)
ENGINE = StripeLog
```
Inserting data:
2020-03-20 10:10:48 +00:00
``` sql
2019-02-04 14:52:31 +00:00
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')
```
2019-02-11 13:32:00 +00:00
We used two `INSERT` queries to create two data blocks inside the `data.bin` file.
2019-02-04 14:52:31 +00:00
2019-02-11 13:32:00 +00:00
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:
2019-02-04 14:52:31 +00:00
2020-03-20 10:10:48 +00:00
``` sql
2019-02-04 14:52:31 +00:00
SELECT * FROM stripe_log_table
```
2020-03-20 10:10:48 +00:00
``` text
2019-02-04 14:52:31 +00:00
┌───────────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):
2020-03-20 10:10:48 +00:00
``` sql
2019-02-04 14:52:31 +00:00
SELECT * FROM stripe_log_table ORDER BY timestamp
```
2020-03-20 10:10:48 +00:00
``` text
2019-02-04 14:52:31 +00:00
┌───────────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 │
└─────────────────────┴──────────────┴────────────────────────────┘
```
2021-09-19 20:05:54 +00:00
[Original article ](https://clickhouse.com/docs/en/operations/table_engines/stripelog/ ) <!--hide-->