Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

devices: use combined ANY clause for faster cleanup #15861

Merged
merged 1 commit into from Jul 3, 2023

Commits on Jul 2, 2023

  1. devices: use combined ANY clause for faster cleanup

    Old device entries for the same user were being removed in individual
    SQL commands, making the batch take way longer than necessary.
    
    This combines the commands into a single one with a IN/ANY clause.
    
    Example of log entry before the change, regularly observed with
    "log_min_duration_statement = 10000" in PostgreSQL's config:
    
        LOG:  duration: 42538.282 ms  statement:
        DELETE FROM device_lists_stream
        WHERE user_id = '@Someone' AND device_id = 'someid1'
        AND stream_id < 123456789
        ;
        DELETE FROM device_lists_stream
        WHERE user_id = '@Someone' AND device_id = 'someid2'
        AND stream_id < 123456789
        ;
        [repeated for each device ID of that user, potentially a lot...]
    
    With the patch applied on my instance for the past couple of days, I
    no longer notice overly long statements of that particular kind.
    
    Signed-off-by: pacien <pacien.trangirard@pacien.net>
    pacien committed Jul 2, 2023
    Configuration menu
    Copy the full SHA
    b0c614e View commit details
    Browse the repository at this point in the history