Skip to content

Commit 83ba5d3

Browse files
authored
feat: add index for dedup copy pipe (CM-1000) (#3900)
Signed-off-by: Umberto Sgueglia <ulemons92@gmail.com> Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent d832a60 commit 83ba5d3

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

services/libs/tinybird/datasources/activities.datasource

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ SCHEMA >
4848
`updatedById` UUID `json:$.updatedById` DEFAULT toUUID('00000000-0000-0000-0000-000000000000'),
4949
`segmentId` LowCardinality(String) `json:$.segmentId` DEFAULT ''
5050

51+
INDEXES >
52+
idx_updatedAt updatedAt TYPE minmax GRANULARITY 1
53+
5154
ENGINE ReplacingMergeTree
5255
ENGINE_PARTITION_KEY toYear(createdAt)
5356
ENGINE_SORTING_KEY id

services/libs/tinybird/datasources/activities_deduplicated_ds.datasource

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ SCHEMA >
3535
INDEXES >
3636
idx_body_ngram3 body TYPE ngrambf_v1(3, 2048, 6, 0) GRANULARITY 64
3737
idx_title_ngram3 title TYPE ngrambf_v1(3, 512, 6, 0) GRANULARITY 64
38+
idx_updatedAt updatedAt TYPE minmax GRANULARITY 1
3839

3940
ENGINE MergeTree
4041
ENGINE_PARTITION_KEY toYear(timestamp)

services/libs/tinybird/pipes/activities_deduplicated_copy_pipe_append_mode.pipe

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ SQL >
1515
a.url,
1616
a.updatedAt
1717
FROM activities a
18-
WHERE a.updatedAt > (SELECT max("updatedAt") FROM activities_deduplicated_ds)
18+
WHERE
19+
a.updatedAt > (
20+
SELECT greatest(max(updatedAt), now() - INTERVAL 3 HOUR)
21+
FROM activities_deduplicated_ds
22+
WHERE updatedAt > now() - INTERVAL 3 HOUR
23+
)
1924

2025
TYPE COPY
2126
TARGET_DATASOURCE activities_deduplicated_ds

0 commit comments

Comments
 (0)