Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PostgreSQL Tuning: O elefante mais rápido que um leopardo

6,976 views

Published on

Palestra realizada em novembro de 2007 no CONISLI, sobre ajuste de performance no PostgreSQL

Published in: Technology
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://shorturl.at/krvUW } ......................................................................................................................... Download Full EPUB Ebook here { http://shorturl.at/krvUW } ......................................................................................................................... Download Full doc Ebook here { http://shorturl.at/krvUW } ......................................................................................................................... Download PDF EBOOK here { http://shorturl.at/krvUW } ......................................................................................................................... Download EPUB Ebook here { http://shorturl.at/krvUW } ......................................................................................................................... Download doc Ebook here { http://shorturl.at/krvUW } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

PostgreSQL Tuning: O elefante mais rápido que um leopardo

  1. 1. por Fernando Ike (90%) e Fábio Telles (10%) PostgreSQL Tuning: O elefante mais rápido que um leopardo 09 de Novembro de 2007
  2. 2. Equilíbrio Difícil
  3. 3. <ul><li>60% dos problemas são relacionados ao mau uso da linguagem SQL; </li></ul><ul><li>20% dos problemas são relacionados a má modelagem do banco de dados; </li></ul><ul><li>10% dos problemas são relacionados a má configuração do SGDB; </li></ul><ul><li>10% dos problemas são relacionados a má configuração do SO. </li></ul>O banco está lento! Problemas comuns
  4. 4. <ul><li>Concentração de regras de negócio na aplicação para processos em lote; </li></ul><ul><li>Integridade referencial na aplicação </li></ul><ul><li>Mal dimensionamento de I/O </li></ul><ul><li>Ambientes virtualizados (Vmware, XEN, etc..) </li></ul><ul><li>Uso de configurações padrões do SO ou do PostgreSQL </li></ul>O banco está lento! Escolhas Erradas
  5. 5. <ul><li>Servidores dedicados para o PostgreSQL </li></ul><ul><li>Storage com Fiber Channel e iSCSI: Grupos de RAID dedicados </li></ul><ul><li>RAID: 0+1 por Hardware </li></ul><ul><li>Mais memória! (Até 4GB em 32 bits) </li></ul><ul><li>Processadores de 64 bits: Performance até 3 vezes do que os 32 bits (AMD64 e EMT64 - Intel) </li></ul>Melhor Hardware
  6. 6. <ul><li>Sistemas Operacionais *nix: Linux (Debian, Gentoo), FreeBSD, Solaris, etc </li></ul><ul><li>Em Linux: use Sistemas de arquivos XFS, Ext3, Ext2 </li></ul><ul><li>Instale a última versão do PostgreSQL (atualmente 8.2) e à partir do código-fonte </li></ul><ul><li>Não usar serviços concorrentes (Apache, MySQL, SAMBA...) em discos, semáforos e shared memory </li></ul>Melhor SO
  7. 7. <ul><li>echo “2” > /proc/sys/vm/overcommit_memory </li></ul><ul><li>echo “25%” > /proc/sys/kernel/shmmax </li></ul><ul><li>echo “25%” > /proc/sys/kernel/shmall </li></ul><ul><li>echo “deadline” > /sys/block/sda/queue/scheduler </li></ul><ul><li>echo “250 32000 100 128” > /proc/sys/kernel/sem </li></ul><ul><li>echo “65536” > /proc/sys/fs/file-max </li></ul><ul><li>ethtool -s eth0 speed 1000 duplex full autoneg off </li></ul>Parâmetros do SO Modificando o *nix
  8. 8. <ul><li>ulimit 65535 </li></ul><ul><li>echo “postgres soft nofile 4096” >> /etc/security/limits </li></ul><ul><li>echo “postgres hard nofile 4096” >> /etc/security/limits </li></ul>Parâmetros do SO Modificando o *nix
  9. 9. <ul><li>Discos ou partições distintos para: </li></ul><ul><ul><li>Logs de transações (WAL) </li></ul></ul><ul><ul><li>Índices: Ext2 </li></ul></ul><ul><ul><li>Tabelas (particionar tabelas grandes) </li></ul></ul><ul><ul><li>Tablespace temporário (em ambiente BI)* </li></ul></ul><ul><ul><li>Archives </li></ul></ul><ul><ul><li>SO + PostgreSQL </li></ul></ul><ul><li>* Novo no PostgreSQL 8.3 </li></ul>Como organizar os Discos O Melhor I/O
  10. 10. <ul><li>max_connections : O menor número possível </li></ul><ul><li>shared buffers : 33% do total -> Para operações em execução </li></ul><ul><li>temp_buffers : Acesso às tabelas temporárias </li></ul><ul><li>work_mem : Para agregação, ordenação, consultas complexas </li></ul><ul><li>maintenance_work_mem : 75% da maior tabela ou índice </li></ul>postgresql.conf Memória
  11. 11. <ul><li>max_fsm_pages : Máximo de páginas necessárias p/ mapear espaço livre. Importante para operações de UPDATE/DELETE. </li></ul><ul><li>wal_sync_method : fdatasync ou open_datasync </li></ul><ul><li>wal_buffers : tamanho do cache para gravação do WAL </li></ul><ul><li>commit_delay : Permite efetivar várias transações na mesma chamada de fsync </li></ul><ul><li>checkpoint_segments : tamanho do cache em disco para operações de escrita </li></ul><ul><li>checkpoint_timeout : intervalo entre os checkpoints </li></ul>postgresql.conf Disco e Wall
  12. 12. <ul><li>Analyze: </li></ul><ul><li>test_base=# EXPLAIN ANALYZE SELECT foo FROM bar; </li></ul><ul><li>Ferramentas: </li></ul><ul><ul><li>Pgfouine; </li></ul></ul><ul><ul><li>Pgadmin3; </li></ul></ul><ul><ul><li>PhpPgAdmin; </li></ul></ul>Tuning de SQL
  13. 13. <ul><li>Autovacuum X Vacuum: Depende do uso (Aplicações Web, OLTI, BI) </li></ul><ul><ul><li>Vacuum: </li></ul></ul><ul><ul><ul><li>vacuum_cost_delay : tempo de atraso para vacuum executar automaticamente nas tabelas grandes </li></ul></ul></ul><ul><ul><li>Autovacuum (ativado por padrão a partir da versão 8.3) : </li></ul></ul><ul><ul><ul><li>autovacuum_naptime : tempo de espera para execução do autovacuum. </li></ul></ul></ul>Manutenção
  14. 14. <ul><li>Escalabilidade vertical: </li></ul><ul><ul><li>Mais e melhores discos; </li></ul></ul><ul><ul><li>Mais memória; </li></ul></ul><ul><ul><li>Melhor processador (quad core, 64bits) </li></ul></ul><ul><li>Escalabilidade horizontal: </li></ul><ul><ul><li>Pgpool I (distribuição de carga de leitura e pool de conexões) </li></ul></ul><ul><ul><li>PgPool II (PgPool I + paralelização de grandes consultas) </li></ul></ul><ul><ul><li>Slony I (Replicação Multi-Master Assíncrona) </li></ul></ul><ul><ul><li>Warm Stand By </li></ul></ul>Quando o tuning não resolve
  15. 15. <ul><li>Documentação Oficial: </li></ul><ul><ul><li>http://www.postgresql.org/docs/ </li></ul></ul><ul><li>Power PostgreSQL: </li></ul><ul><ul><li>http://www.powerpostgresql.com/ </li></ul></ul><ul><li>PostgreSQL Brasil: </li></ul><ul><ul><li>http://www.postgresql.org.br </li></ul></ul><ul><li>Teste de estresse com soluções livres e proprietárias: </li></ul><ul><ul><li>http://www.vivaolinux.com.br/artigos/verArtigo.php?codigo=7053&pagina=5 </li></ul></ul><ul><li>Benchmark Brou-Ha-Ha </li></ul><ul><ul><li>http://blogs.ittoolbox.com/database/soup/archives/benchmark-brouhaha-17939 </li></ul></ul>Links
  16. 16. <ul><li>Listas de discussão: </li></ul><ul><ul><li>http://archives.postgresql.org/pgsql-performance/ </li></ul></ul><ul><ul><li>https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral </li></ul></ul><ul><li>IRC irc.freenodes.net: </li></ul><ul><ul><li>#POSTGRESQL </li></ul></ul><ul><ul><li>#POSTGRESQL-BR </li></ul></ul>Dúvidas
  17. 17. <ul><li>Fábio Telles: </li></ul><ul><ul><li>[email_address] </li></ul></ul><ul><ul><li>http://www.midstorm.org/~telles </li></ul></ul><ul><li>Fernando Ike </li></ul><ul><ul><li>[email_address] </li></ul></ul><ul><ul><li>http://www.midstorm.org/~fike/weblog </li></ul></ul>Contato
  18. 18. <ul><li>7 e 8 de Dezembro </li></ul><ul><li>Centro de Convenções Pompéia (São Paulo – SP) </li></ul><ul><li>http://pgcon.postgresql.org.br </li></ul><ul><li>http://www.temporealeventos.com.br </li></ul>

×