Skip to content
Snippets Groups Projects
  1. Jun 01, 2020
    • Dagfinn Ilmari Mannsåker's avatar
      Improve performance of _get_state_groups_from_groups_txn (#7567) · df8a3cef
      Dagfinn Ilmari Mannsåker authored
      The query keeps showing up in my slow query log.
      
      This changes the plan under the top-level Sort node from
      
      ```
          WindowAgg  (cost=280335.88..292963.15 rows=561212 width=80) (actual time=138.651..160.562 rows=27112 loops=1)
            ->  Sort  (cost=280335.88..281738.91 rows=561212 width=84) (actual time=138.597..140.622 rows=27112 loops=1)
                  Sort Key: state_groups_state.type, state_groups_state.state_key, state_groups_state.state_group
                  Sort Method: quicksort  Memory: 4581kB
                  ->  Nested Loop  (cost=2.83..226745.22 rows=561212 width=84) (actual time=21.548..47.657 rows=27112 loops=1)
                        ->  HashAggregate  (cost=2.27..3.28 rows=101 width=8) (actual time=21.526..21.535 rows=20 loops=1)
                              Group Key: state.state_group
                              ->  CTE Scan on state  (cost=0.00..2.02 rows=101 width=8) (actual time=21.280..21.493 rows=20 loops=1)
                        ->  Index Scan using state_groups_state_type_idx on state_groups_state  (cost=0.56..2189.40 rows=5557 width=84) (actual time=0.005..0.991 rows=1356 loops=20)
                              Index Cond: (state_group = state.state_group)
      ```
      
      to
      
      ```
          Nested Loop  (cost=2.83..226745.22 rows=561212 width=84) (actual time=24.194..52.834 rows=27112 loops=1)
            ->  HashAggregate  (cost=2.27..3.28 rows=101 width=8) (actual time=24.130..24.138 rows=20 loops=1)
                  Group Key: state.state_group
                  ->  CTE Scan on state  (cost=0.00..2.02 rows=101 width=8) (actual time=23.887..24.113 rows=20 loops=1)
            ->  Index Scan using state_groups_state_type_idx on state_groups_state  (cost=0.56..2189.40 rows=5557 width=84) (actual time=0.016..1.159 rows=1356 loops=20)
                  Index Cond: (state_group = state.state_group)
      ```
      
      This cuts the execution time from ~190ms to ~130ms, i.e. a reduction
      of ~30%.
      
      The full plans are visualised at https://explain.depesz.com/s/WpbT and
      https://explain.depesz.com/s/KlEk
      
      
      
      Signed-off-by: default avatarDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
      df8a3cef
    • Patrick Cloke's avatar
    • Brendan Abolivier's avatar
      Don't fail all of an iteration of the device list retry loop on error (#7609) · c1bdd4fa
      Brendan Abolivier authored
      Without this patch, if an error happens which isn't caught by `user_device_resync`, then `_maybe_retry_device_resync` would fail, without retrying the next users in the iteration. This patch fixes this so that it now only logs an error in this case.
      c1bdd4fa
    • Dagfinn Ilmari Mannsåker's avatar
  2. May 30, 2020
  3. May 29, 2020
  4. May 28, 2020
  5. May 27, 2020
  6. May 26, 2020
  7. May 23, 2020
    • Richard van der Hoff's avatar
      Simplify reap_monthly_active_users (#7558) · d14c4d6b
      Richard van der Hoff authored
      we can use `make_in_list_sql_clause` rather than doing our own half-baked
      equivalent, which has the benefit of working just fine with empty lists.
      
      (This has quite a lot of tests, so I think it's pretty safe)
      d14c4d6b
Loading