Query in PostgreSQL became slow and then got better on its own - why?PostgreSQL 9.3 - Performance Issue:...

Yosemite Fire Rings - What to Expect?

How do apertures which seem too large to physically fit work?

How to explain what's wrong with this application of the chain rule?

Why does the Sun have different day lengths, but not the gas giants?

Extract more than nine arguments that occur periodically in a sentence to use in macros in order to typset

Quoting Keynes in a lecture

Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?

Keeping a ball lost forever

How does the math work for Perception checks?

Can a stoichiometric mixture of oxygen and methane exist as a liquid at standard pressure and some (low) temperature?

Lowest total scrabble score

Why would a new[] expression ever invoke a destructor?

Plot of a tornado-shaped surface

Can the US President recognize Israel’s sovereignty over the Golan Heights for the USA or does that need an act of Congress?

What if a revenant (monster) gains fire resistance?

What should you do when eye contact makes your subordinate uncomfortable?

It grows, but water kills it

Unexpected behavior of the procedure `Area` on the object 'Polygon'

Does Doodling or Improvising on the Piano Have Any Benefits?

Redundant comparison & "if" before assignment

Creepy dinosaur pc game identification

Limits and Infinite Integration by Parts

Biological Blimps: Propulsion

What is going on with 'gets(stdin)' on the site coderbyte?



Query in PostgreSQL became slow and then got better on its own - why?


PostgreSQL 9.3 - Performance Issue: Counting table entries slower with jdbc postgres driverPostgres 9.4.4 query takes foreverQuery planner slow to use newly created index on database under heavy loadUsing an index on a Postgresql integer range causing troubleIs the transfer time from PostgreSQL to the application optimisable?Centos 6 / Postgres 9.3 periodic “pauses”Speed up query calculation. Where can I add indexes or optimize the query or server?PostgreSQL DELETE query hangs (and so does EXPLAIN ANALYZE!)First run of planner very slow on massively partitioned PostgreSQL 9.6 tablePostgreSQL - shared buffers expiration













0















I want to better understand how to debug and fix performance issues in PostgreSQL.



I have a query that usually costs 1 second to run. However, for some reason, it started taking 30 seconds to run for a period of time! After some minutes and some explain analyze invocations, it went back to normal. I didn't do anything to fix it, nor did I understand why it got better all of a sudden.



How do I debug a problem like this? What kind of logging and instrumentation should I have in place to understand what caused this and how to fix it?










share|improve this question
















bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    System busy overall? Table(s) undergoing a large update? Large analytic type query being run? The Gods not appreciating your invocations? :-) On a more serious note, this is the reason you should have monitoring software installed before problems arise! Do you have anything like sysstat or nagios or similar?

    – Vérace
    Apr 19 '18 at 3:14











  • No. Just some simple logs in pg. Was considering using the ELK stack to get all kinds of verbose logs

    – ivarec
    Apr 19 '18 at 3:15






  • 1





    Have you considered the excellent (and Open Source) sysstat tools?

    – Vérace
    Apr 19 '18 at 3:34











  • Go this link. It may help you..! dbrnd.com/2016/02/…

    – Ramanna Gunde
    Apr 19 '18 at 5:41
















0















I want to better understand how to debug and fix performance issues in PostgreSQL.



I have a query that usually costs 1 second to run. However, for some reason, it started taking 30 seconds to run for a period of time! After some minutes and some explain analyze invocations, it went back to normal. I didn't do anything to fix it, nor did I understand why it got better all of a sudden.



How do I debug a problem like this? What kind of logging and instrumentation should I have in place to understand what caused this and how to fix it?










share|improve this question
















bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    System busy overall? Table(s) undergoing a large update? Large analytic type query being run? The Gods not appreciating your invocations? :-) On a more serious note, this is the reason you should have monitoring software installed before problems arise! Do you have anything like sysstat or nagios or similar?

    – Vérace
    Apr 19 '18 at 3:14











  • No. Just some simple logs in pg. Was considering using the ELK stack to get all kinds of verbose logs

    – ivarec
    Apr 19 '18 at 3:15






  • 1





    Have you considered the excellent (and Open Source) sysstat tools?

    – Vérace
    Apr 19 '18 at 3:34











  • Go this link. It may help you..! dbrnd.com/2016/02/…

    – Ramanna Gunde
    Apr 19 '18 at 5:41














0












0








0








I want to better understand how to debug and fix performance issues in PostgreSQL.



I have a query that usually costs 1 second to run. However, for some reason, it started taking 30 seconds to run for a period of time! After some minutes and some explain analyze invocations, it went back to normal. I didn't do anything to fix it, nor did I understand why it got better all of a sudden.



How do I debug a problem like this? What kind of logging and instrumentation should I have in place to understand what caused this and how to fix it?










share|improve this question
















I want to better understand how to debug and fix performance issues in PostgreSQL.



I have a query that usually costs 1 second to run. However, for some reason, it started taking 30 seconds to run for a period of time! After some minutes and some explain analyze invocations, it went back to normal. I didn't do anything to fix it, nor did I understand why it got better all of a sudden.



How do I debug a problem like this? What kind of logging and instrumentation should I have in place to understand what caused this and how to fix it?







postgresql postgresql-performance postgresql-10






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 19 '18 at 2:04







ivarec

















asked Apr 19 '18 at 1:46









ivarecivarec

948




948





bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 1





    System busy overall? Table(s) undergoing a large update? Large analytic type query being run? The Gods not appreciating your invocations? :-) On a more serious note, this is the reason you should have monitoring software installed before problems arise! Do you have anything like sysstat or nagios or similar?

    – Vérace
    Apr 19 '18 at 3:14











  • No. Just some simple logs in pg. Was considering using the ELK stack to get all kinds of verbose logs

    – ivarec
    Apr 19 '18 at 3:15






  • 1





    Have you considered the excellent (and Open Source) sysstat tools?

    – Vérace
    Apr 19 '18 at 3:34











  • Go this link. It may help you..! dbrnd.com/2016/02/…

    – Ramanna Gunde
    Apr 19 '18 at 5:41














  • 1





    System busy overall? Table(s) undergoing a large update? Large analytic type query being run? The Gods not appreciating your invocations? :-) On a more serious note, this is the reason you should have monitoring software installed before problems arise! Do you have anything like sysstat or nagios or similar?

    – Vérace
    Apr 19 '18 at 3:14











  • No. Just some simple logs in pg. Was considering using the ELK stack to get all kinds of verbose logs

    – ivarec
    Apr 19 '18 at 3:15






  • 1





    Have you considered the excellent (and Open Source) sysstat tools?

    – Vérace
    Apr 19 '18 at 3:34











  • Go this link. It may help you..! dbrnd.com/2016/02/…

    – Ramanna Gunde
    Apr 19 '18 at 5:41








1




1





System busy overall? Table(s) undergoing a large update? Large analytic type query being run? The Gods not appreciating your invocations? :-) On a more serious note, this is the reason you should have monitoring software installed before problems arise! Do you have anything like sysstat or nagios or similar?

– Vérace
Apr 19 '18 at 3:14





System busy overall? Table(s) undergoing a large update? Large analytic type query being run? The Gods not appreciating your invocations? :-) On a more serious note, this is the reason you should have monitoring software installed before problems arise! Do you have anything like sysstat or nagios or similar?

– Vérace
Apr 19 '18 at 3:14













No. Just some simple logs in pg. Was considering using the ELK stack to get all kinds of verbose logs

– ivarec
Apr 19 '18 at 3:15





No. Just some simple logs in pg. Was considering using the ELK stack to get all kinds of verbose logs

– ivarec
Apr 19 '18 at 3:15




1




1





Have you considered the excellent (and Open Source) sysstat tools?

– Vérace
Apr 19 '18 at 3:34





Have you considered the excellent (and Open Source) sysstat tools?

– Vérace
Apr 19 '18 at 3:34













Go this link. It may help you..! dbrnd.com/2016/02/…

– Ramanna Gunde
Apr 19 '18 at 5:41





Go this link. It may help you..! dbrnd.com/2016/02/…

– Ramanna Gunde
Apr 19 '18 at 5:41










1 Answer
1






active

oldest

votes


















0














It is a very broad question, even more so as you give absolutely no details about your setup and kind of database (volume, type of queries, active connections, size of RAM, dedicated server or not, etc.)



You can start by enabling PostgreSQL to log slow queries, see the log_min_duration_statement in the configuration. That will give you historical data that you would then be able to analyze and maybe correlate with other things (like from the list of @Vérace)



You will then have various tools to help, as described on https://wiki.postgresql.org/wiki/Logging_Difficult_Queries :




  • pgFouine

  • PQA

  • EPQA

  • pgsi






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "182"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f204388%2fquery-in-postgresql-became-slow-and-then-got-better-on-its-own-why%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It is a very broad question, even more so as you give absolutely no details about your setup and kind of database (volume, type of queries, active connections, size of RAM, dedicated server or not, etc.)



    You can start by enabling PostgreSQL to log slow queries, see the log_min_duration_statement in the configuration. That will give you historical data that you would then be able to analyze and maybe correlate with other things (like from the list of @Vérace)



    You will then have various tools to help, as described on https://wiki.postgresql.org/wiki/Logging_Difficult_Queries :




    • pgFouine

    • PQA

    • EPQA

    • pgsi






    share|improve this answer




























      0














      It is a very broad question, even more so as you give absolutely no details about your setup and kind of database (volume, type of queries, active connections, size of RAM, dedicated server or not, etc.)



      You can start by enabling PostgreSQL to log slow queries, see the log_min_duration_statement in the configuration. That will give you historical data that you would then be able to analyze and maybe correlate with other things (like from the list of @Vérace)



      You will then have various tools to help, as described on https://wiki.postgresql.org/wiki/Logging_Difficult_Queries :




      • pgFouine

      • PQA

      • EPQA

      • pgsi






      share|improve this answer


























        0












        0








        0







        It is a very broad question, even more so as you give absolutely no details about your setup and kind of database (volume, type of queries, active connections, size of RAM, dedicated server or not, etc.)



        You can start by enabling PostgreSQL to log slow queries, see the log_min_duration_statement in the configuration. That will give you historical data that you would then be able to analyze and maybe correlate with other things (like from the list of @Vérace)



        You will then have various tools to help, as described on https://wiki.postgresql.org/wiki/Logging_Difficult_Queries :




        • pgFouine

        • PQA

        • EPQA

        • pgsi






        share|improve this answer













        It is a very broad question, even more so as you give absolutely no details about your setup and kind of database (volume, type of queries, active connections, size of RAM, dedicated server or not, etc.)



        You can start by enabling PostgreSQL to log slow queries, see the log_min_duration_statement in the configuration. That will give you historical data that you would then be able to analyze and maybe correlate with other things (like from the list of @Vérace)



        You will then have various tools to help, as described on https://wiki.postgresql.org/wiki/Logging_Difficult_Queries :




        • pgFouine

        • PQA

        • EPQA

        • pgsi







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 2 '18 at 15:56









        Patrick MevzekPatrick Mevzek

        6641416




        6641416






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Database Administrators Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f204388%2fquery-in-postgresql-became-slow-and-then-got-better-on-its-own-why%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Anexo:Material bélico de la Fuerza Aérea de Chile Índice Aeronaves Defensa...

            Always On Availability groups resolving state after failover - Remote harden of transaction...

            update json value to null Announcing the arrival of Valued Associate #679: Cesar Manara ...