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

*: Support 'TTL'(like the one in HBase) in TiDB #18731

Closed
tianyu4552 opened this issue Jul 22, 2020 · 11 comments
Closed

*: Support 'TTL'(like the one in HBase) in TiDB #18731

tianyu4552 opened this issue Jul 22, 2020 · 11 comments
Labels
feature/discussing This feature request is discussing among product managers type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@tianyu4552
Copy link

我们现在遇到一个问题,我们打算建一个数据基础维表,数据会被周更。
但是周更的过程不能保证100%全量覆盖,但不希望旧数据被命中出来,这样上层使用方需要做额外处理。
能否像HBase的TTL机制那样,有过期淘汰策略。
可以接受以rowId为主键,对整条数据过过期处理

Now we have a problem. We plan to build a basic dimension table of data, and the data will be updated weekly.

However, the weekly shift process can not guarantee 100% full coverage, but the old data is not expected to be hit, so the upper users need to do additional processing.

Can there be a strategy of expiration and elimination like the TTL mechanism of HBase.

It is acceptable to use rowId as the primary key to process the whole data after expiration

@tianyu4552 tianyu4552 added the type/feature-request Categorizes issue or PR as related to a new feature. label Jul 22, 2020
@bb7133
Copy link
Member

bb7133 commented Jul 22, 2020

Hi @tianyu4552 , thanks for reporting this request!

Would you mind modifying the title to English, please? Generally, it would be better if everyone is able to understand it.

@bb7133 bb7133 changed the title 如果tidb能具有HBase那样的TTL机制就好了 *: Support 'TTL'(like the one in HBase) in TiDB Jul 27, 2020
@bb7133
Copy link
Member

bb7133 commented Jul 27, 2020

Hi @tianyu4552 I've translated the title in English, hope that it can be accepted, thank you!

@ghost
Copy link

ghost commented Jul 31, 2020

MongoDB also has something called capped collections.

I think an sql-like way to do this would be with partitioning + truncate partition. We could look at the syntax of interval partitioning (oracle feature) and add syntax to retain only the last n partitions.

@zz-jason
Copy link
Member

read from the old partition, update it, write it to the new partition, truncate the old partition periodically. @nullnotnil Am I correct?

@ghost
Copy link

ghost commented Jul 31, 2020

@zz-jason To be TTL based there would need to be a partition on modified_date. An update to an old partition would auto-move it to the newest partition. It would need some design work, but I like the idea of ttl based tables in principal. It solves a pain point of users that fail trying to do this themselves (with delete statements).

@zz-jason zz-jason added the feature/reviewing This feature request is reviewing by product managers label Aug 6, 2020
@zz-jason
Copy link
Member

zz-jason commented Aug 6, 2020

here is the reference from HBase Time To Live (TTL):

ColumnFamilies can set a TTL length in seconds, and HBase will automatically delete rows once the expiration time is reached. This applies to all versions of a row - even the current one. The TTL time encoded in the HBase for the row is specified in UTC.

@ghost
Copy link

ghost commented Aug 6, 2020

See also: https://www.percona.com/blog/2020/08/04/the-road-story-of-a-myrocks-mariadb-migration/

This describes the use of a TTL in the SHOW CREATE TABLE statement.

@zz-jason zz-jason added feature/discussing This feature request is discussing among product managers and removed feature/reviewing This feature request is reviewing by product managers labels Aug 10, 2020
@tianyu4552
Copy link
Author

I feel that we can declare the TTL mechanism which is work on row or partition by CREATE TABLE statement, and it should be automated.

@scsldb
Copy link

scsldb commented Aug 28, 2020

We need to investigate the user scenario in depth, and then make a decision after the research is completed.

@ghost
Copy link

ghost commented Aug 28, 2020

See https://brandur.org/fragments/ttl-indexes and https://docs.mongodb.com/manual/core/index-ttl/ for another implementation type. This makes it an index property rather than a table property.

@SunRunAway
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/discussing This feature request is discussing among product managers type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

5 participants