Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
docs: RFC for TTL tables #39264
docs: RFC for TTL tables #39264
Changes from 11 commits
1c327a1
6cb2c91
91f78ac
02c30ac
e201649
25850fa
56f9da4
cb6b2d3
dbeeba5
d2a9605
3868907
bfe2ed7
4867da9
ce3fb33
501a330
c75ff9e
18fe079
e19989e
3511a2b
fa73868
51b87b7
29e3726
d4196fa
49b388a
a0137d3
c2f27da
2d094f2
7200043
9301a17
3a759ff
4b5aa55
1e6585c
630b1e6
2020fac
a290eea
c0cbec0
ed0c3f8
41b45fb
4a0cf1e
f9b0515
88b0077
a202c34
87c3465
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we pass -3 MONTH here?
btw, seem here should be "3 MONTHS", plural.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, I prefer Spanner's TTL Clause https://cloud.google.com/spanner/docs/ttl/working-with-ttl#postgresql
creating a TTL "ON" a column may be more straightforward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is allowed currently, but meaningless in most times. If one row is created using the real time, it will be deleted after next job scheduled, so it equals to setting the expire interval to a very small value. If user sets a time in one row with a past time, it may be some different, but I don't know any scene requires it. Maybe we can disallow user to setting it a a negative value or just leave it alone because it will not bring some big problem.
We are using an expression to parse the duration, so, it supports both
3 MONTH
and3 MONTHS
. I can update it plural in doc to make it more naturalI do not have a strong preference, PTAL @SunRunAway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer keeping it as an expression syntax instead of a particular syntax because there may be more syntax extensions in the future if you don't have a strong opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the doc.
Just to confirm one thing: this will work even for virtual column?
Imagine if we have an existing table like below with a lot of data, and created_at is unix timestamp in nanosecond.
CREATE TABLE t1 (
id int PRIMARY KEY,
created_at long
)
We dont want to modify existing schema to add a 'DateTime' or 'Date' field, which may cause a lot of existing data to be rewritten.
So I just want to confirm below way can work as expected:
ALTER TABLE t1 ADD column timestamp_ttl bigint AS (FROM_UNIXTIME(created_at/1000000000)) VIRTUAL;
ALTER TABLE t1 ADD TTL = 'timestamp_ttl + INTERVAL 180 DAYS';
If so, can you please help document that (how to enable that on existing tables using long in a light way(without rewriting data))?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it supports generated column with some limitations. Because currently generated column can not be pushed down, so it make take more performance, we'll optimize it in the future. It is documented: https://github.com/pingcap/tidb/pull/39264/files#diff-3199b62f6b171f846c9c0c1670428817d339e0e2ee2b2a35822df8f532c51e58R202
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick response!
Just curious how is pushdown involved here, isn't this just some micro batch scan and delete statements?
If there is indeed a performance overhead even for this scan+delete approach, is it possible to just support column with the type of LONG (unix timestamp)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lcwangchao
Could you add a section about "generated column" in this document to elaborate clearly?
We can talk about the compatibility about the generated column and the solution to optimize the generated column calculation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful to put this toward the top so readers know, right away, that we've considered these options.