Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
An illustrated guide to
  the buffer cache
               Selena Deckelmann
  Based on Greg Smith’s “Inside the Buffer Cac...
Table

Databases                        Table


                                 Table



     Databases are made of table...
$PGDATA/base/                 Table




    A table is just a directory...
$PGDATA/base/               Table


                            Table

                            Table


  You can have ...
$PGDATA/base/   Table

                Table

                Table   Made of           Made o
                           ...
shared_buffers
shared_buffers

       ptr   ptr   ptr   ptr   ptr   ...

      An array of pointers to 8K blocks
           (and some oth...
shared_buffers:
 the other stuff
FREE FREE FREE FREE FREE FREE



       In the beginning...
shared_buffers:
 the other stuff
FREE FREE FREE FREE FREE FREE
 456  12   100 612   32   409
shared_buffers:
the other stuff
 X    X     X     X    X     X
456   12   100   612   32   409
shared_buffers:
         the other stuff
         X         X         X         X         X         X
Tag   base/file1 base...
shared_buffers:
            the other stuff
            X         X         X         X         X         X
  Tag    base/...
shared_buffers:
            the other stuff
            X         X         X         X         X         X
  Tag    base/...
shared_buffers:
            the other stuff
            X         X         X         X         X         X
  Tag    base/...
shared_buffers:
            the other stuff
            X         X         X         X         X         X
  Tag    base/...
shared_buffers:
            the other stuff
            X         X         X         X         X         X
  Tag    base/...
shared_buffers:
     the lifecycle
   X         X         X         X         X         X
base/file1 base/file2 base/file1 ba...
shared_buffers:
     the lifecycle
   X         X         X         X         X         X
base/file1 base/file2 base/file1 ba...
shared_buffers:
     the lifecycle
   X         X         X         X         X         X
base/file1 base/file2 base/file1 ba...
shared_buffers:
                 the lifecycle
                      Who’s it gonna be?
               X         X        ...
shared_buffers:
                the lifecycle
                     Who’s it gonna be?
              X         X         X ...
shared_buffers:
     the lifecycle
          Who’s it gonna be?
   X         X         X         X         X         X
bas...
shared_buffers:
     the lifecycle
          Who’s it gonna be?
   X         X         X         X         X         X
bas...
shared_buffers:
                   optimizations*
         X         X         X         X         X         X         X  ...
shared_buffers:
                    optimizations
         X         X         X         X         X         X         X  ...
shared_buffers:
                    optimizations VACUUM
                                  Safe during

        OVERSIMPLI...
Prochain SlideShare
Chargement dans…5
×
Prochain SlideShare
Morgen e-Learning in je klas
Suivant
Télécharger pour lire hors ligne et voir en mode plein écran

4

Partager

Télécharger pour lire hors ligne

Illustrated buffer cache

Télécharger pour lire hors ligne

Illustrated buffer cache

  1. 1. An illustrated guide to the buffer cache Selena Deckelmann Based on Greg Smith’s “Inside the Buffer Cache” http://www.westnet.com/∼gsmith/content/postgresql
  2. 2. Table Databases Table Table Databases are made of tables...
  3. 3. $PGDATA/base/ Table A table is just a directory...
  4. 4. $PGDATA/base/ Table Table Table You can have more than one table.
  5. 5. $PGDATA/base/ Table Table Table Made of Made o f 8K File 8K 8K File 8K 8K File 8K File 8K ... ... Up to 1 GB Files are made up of 8K blocks.* * you can change that at compile time.
  6. 6. shared_buffers
  7. 7. shared_buffers ptr ptr ptr ptr ptr ... An array of pointers to 8K blocks (and some other stuff) shared_buffers is configured at database start. You have to restart Postgres to change it.
  8. 8. shared_buffers: the other stuff FREE FREE FREE FREE FREE FREE In the beginning...
  9. 9. shared_buffers: the other stuff FREE FREE FREE FREE FREE FREE 456 12 100 612 32 409
  10. 10. shared_buffers: the other stuff X X X X X X 456 12 100 612 32 409
  11. 11. shared_buffers: the other stuff X X X X X X Tag base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 409
  12. 12. shared_buffers: the other stuff X X X X X X Tag base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 409 Status FLAGS FLAGS FLAGS FLAGS FLAGS FLAGS
  13. 13. shared_buffers: the other stuff X X X X X X Tag base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 409 Status PINNED flags flags flags flags flags { } UPDATE mytable (status) VALUES(‘my cat is the best ever’) where user = ‘selenamarie’;
  14. 14. shared_buffers: the other stuff X X X X X X Tag base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 409 Status PINNED DIRTY flags flags flags flags { COMMIT; }
  15. 15. shared_buffers: the other stuff X X X X X X Tag base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 409 Status PINNED DIRTY OTHER OTHER OTHER OTHER { BLAH BLAH BLAH; }
  16. 16. shared_buffers: the other stuff X X X X X X Tag base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 409 Status PINNED DIRTY OTHER OTHER OTHER OTHER Usage 1 5 5 4 3 0
  17. 17. shared_buffers: the lifecycle X X X X X X base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 409 PINNED DIRTY OTHER OTHER OTHER OTHER 1 5 5 4 3 0 { myPgProcess calls: BufferAlloc(‘base/file1’, 100); }
  18. 18. shared_buffers: the lifecycle X X X X X X base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 409 PINNED DIRTY PINNED OTHER OTHER OTHER 1 5 5 4 3 0 { myPgProcess calls: BufferAlloc(‘base/file1’, 100); }
  19. 19. shared_buffers: the lifecycle X X X X X X base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 409 PINNED DIRTY OTHER OTHER OTHER OTHER 1 5 5 4 3 0 { myPgProcess calls: BufferAlloc(‘base/file1’, 101); }
  20. 20. shared_buffers: the lifecycle Who’s it gonna be? X X X X X X base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 409 PINNED DIRTY OTHER OTHER OTHER OTHER 1 5 5 4 3 0 Eviction! { myPgProcess calls: BufferAlloc(‘base/file1’, 101); }
  21. 21. shared_buffers: the lifecycle Who’s it gonna be? X X X X X X base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 409 PINNED DIRTY OTHER OTHER OTHER OTHER 0 5 5 4 3 0 Scan the cache! Usage != 0, so decrement. { myPgProcess calls: BufferAlloc(‘base/file1’, 101); }
  22. 22. shared_buffers: the lifecycle Who’s it gonna be? X X X X X X base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 Usage == 0, 456 12 100 612 32 409 Goodbye! PINNED DIRTY OTHER OTHER OTHER OTHER 0 4 4 3 2 0 { myPgProcess calls: BufferAlloc(‘base/file1’, 101); }
  23. 23. shared_buffers: the lifecycle Who’s it gonna be? X X X X X X base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 456 12 100 612 32 101 PINNED DIRTY OTHER OTHER OTHER PINNED 0 4 4 3 2 1 { myPgProcess calls: BufferAlloc(‘base/file1’, 101); }
  24. 24. shared_buffers: optimizations* X X X X X X X ... base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 base/file2 ... 456 12 100 612 32 101 891 ... PINNED DIRTY OTHER OTHER OTHER PINNED OTHER ... 0 4 4 3 2 0 1 ... { } Result is greater than: SELECT pg_relation_size(‘mytable’); shared_buffers/4 VACUUM mytable; * Version 8.3 and later
  25. 25. shared_buffers: optimizations X X X X X X X ... base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 base/file2 ... 456 12 100 612 32 101 891 ... PINNED DIRTY OTHER OTHER OTHER PINNED OTHER ... 0 4 4 3 2 0 1 ... 256K ring buffer allocated! { SELECT pg_relation_size(‘mytable’); VACUUM mytable; } * Version 8.3 and later
  26. 26. shared_buffers: optimizations VACUUM Safe during OVERSIMPLIFICATION WARNING! X X X X X X X ... base/file1 base/file2 base/file1 base/file3 base/file1 base/file1 base/file2 ... 456 12 100 612 32 101 891 ... PINNED DIRTY OTHER OTHER OTHER PINNED OTHER ... 0 4 4 3 2 0 1 ... 256K ring buffer allocated! { SELECT pg_relation_size(‘mytable’); VACUUM mytable; } * Version 8.3 and later
  • KetanPatel219

    May. 1, 2018
  • darthkremer

    May. 24, 2017
  • AnastasiaLubennikova

    Apr. 20, 2016
  • snaga

    Feb. 24, 2011

Vues

Nombre de vues

2 934

Sur Slideshare

0

À partir des intégrations

0

Nombre d'intégrations

25

Actions

Téléchargements

42

Partages

0

Commentaires

0

Mentions J'aime

4

×