Skip to content

how to delete data at specific hour #64

Closed

Description

@exitNA

I have

CREATE TABLE default.toy
(
    day Date, 
    hour Int8, 
    info String
) ENGINE = MergeTree(day, (day, hour), 1024)

and, batch inserting data every hour. from the doc I can drop a partition of a month, but if there is one hour dirty data inserted, how to delete this hour's data? I don't want to drop all partition of that month.
can i do subpartition by day, by hour?

Activity

  1. alexey-milovidov commented on Jul 29, 2016

    @alexey-milovidov
    Member

    There is no way to delete data with granularity less than partitions, and it is not possible to define custom partitions rather than month.

    Both features are possible to implement and we have plans for it (not in near perspective, definitely later than Q3).

  2. andrea-s commented on Jul 31, 2016

    @andrea-s

    What about selecting all the data that we need in a new table, dropping the old one, and selecting it back? Would that be safe, Alexey?

  3. alexey-milovidov commented on Jul 31, 2016

    @alexey-milovidov
    Member

    Yes, it is safe
    (create a new table, do INSERT SELECT of all "right" data into it, and then do DROP, RENAME).

  4. goranc commented on Nov 21, 2016

    @goranc

    You can use tables with suffix based on hour, as stage tables, and insert data in specific table. Selecting using Merge table type as virtual view to all tables based on hour.
    Eg. use script to create 365 x 24 tables in stage database, like stage.table_yyyymmdd_hh and use Merge(stage, '^table') to select data.
    That way you will be able to drop single table based on hour.

  5. daledude commented on Apr 1, 2017

    @daledude

    What are the performance implications of doing queries spanning a month over a merge table that has 365 x 24 tables under it? The docs for merge engine say queries are parallel so there will be 30 x 24 queries run at the same time?

  6. alexey-milovidov commented on Apr 7, 2017

    @alexey-milovidov
    Member

    What are the performance implications of doing queries spanning a month over a merge table that has 365 x 24 tables under it?

    Every query, even simple one, will require to do at least 365 * 24 * num_used_columns disk seeks.
    For short-running queries this will be very expensive.

    The docs for merge engine say queries are parallel so there will be 30 x 24 queries run at the same time?

    Tables are processed in parallel but with limited number of threads. There will be max_threads (default = number of physical CPU cores) and each of them will process some subset of all tables.

  7. harlinb commented on Nov 17, 2017

    @harlinb

    Potentially solved by #1482

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions