Skip to content
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

chore(mm-bot): add indexes to database #229

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

NicolasRampoldi
Copy link

@NicolasRampoldi NicolasRampoldi commented Apr 11, 2024

Description

  • Add indexes to database to improve performance of sorted columns.

Results

  • Queries in replica improved speed performance up to 2x.

Before Index

In primary:

   Sort Key: amount
   Sort Method: quicksort  Memory: 69kB
   Buffers: shared hit=6
   ->  Seq Scan on orders  (cost=0.00..7.90 rows=190 width=389) (actual time=0.011..0.035 rows=190 loops=1)
         Buffers: shared hit=6
 Planning Time: 0.059 ms
 Execution Time: 0.146 ms
(8 rows)

In replica:

 Sort  (cost=15.09..15.57 rows=190 width=389) (actual time=0.151..0.162 rows=190 loops=1)
   Sort Key: amount
   Sort Method: quicksort  Memory: 69kB
   Buffers: shared hit=9
   ->  Seq Scan on orders  (cost=0.00..7.90 rows=190 width=389) (actual time=0.006..0.035 rows=190 loops=1)
         Buffers: shared hit=6
 Planning:
   Buffers: shared hit=156 read=2
 Planning Time: 0.498 ms
 Execution Time: 0.212 ms
(10 rows)

After Index

In primary:

 Sort  (cost=15.09..15.57 rows=190 width=389) (actual time=0.106..0.117 rows=190 loops=1)
   Sort Key: amount
   Sort Method: quicksort  Memory: 69kB
   Buffers: shared hit=6
   ->  Seq Scan on orders  (cost=0.00..7.90 rows=190 width=389) (actual time=0.007..0.031 rows=190 loops=1)
         Buffers: shared hit=6
 Planning:
   Buffers: shared hit=15 read=1
 Planning Time: 0.203 ms
 Execution Time: 0.142 ms
(10 rows)

In replica:

 Sort  (cost=15.09..15.57 rows=190 width=389) (actual time=0.108..0.119 rows=190 loops=1)
   Sort Key: amount
   Sort Method: quicksort  Memory: 69kB
   Buffers: shared hit=6
   ->  Seq Scan on orders  (cost=0.00..7.90 rows=190 width=389) (actual time=0.006..0.029 rows=190 loops=1)
         Buffers: shared hit=6
 Planning:
   Buffers: shared hit=21
 Planning Time: 0.171 ms
 Execution Time: 0.144 ms
(10 rows)

@JuArce JuArce merged commit 7fa7c9a into develop Apr 11, 2024
3 checks passed
@JuArce JuArce deleted the chore(mm-bot)/228-add-indexes-to-database branch April 11, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants