Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Solved postgresql configuration / slow log

    Support
    postgresql
    4
    8
    193
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • vladimir.d
      vladimir.d last edited by girish

      We need to enable postgresql slow query logging and we have done the following:

      $ docker exec -ti postgresql bash
      $ psql -d MY_DATABASE_NAME
      
      psql (12.10 (Ubuntu 12.10-1.pgdg20.04+1+b1))
      Type "help" for help.
      
      MY_DATABASE_NAME =# ALTER DATABASE MY_DATABASE_NAME SET log_min_duration_statement = 5000;
      
      MY_DATABASE_NAME =# SELECT pg_sleep(15);
      

      But the slow log file didn't appear anywhere (/run/postgresql, /var/log/postgresql, /var/lib/postgresql/12/main/).

      We need to set logging_collector to on in the postgresql config /etc/postgresql/12/main/postgresql.conf which is read-only.

      Also please advise how to amend postgresql configuration in reboot/upgrade safe way.

      vladimir.d 1 Reply Last reply Reply Quote 1
      • vladimir.d
        vladimir.d @vladimir.d last edited by

        @girish could you amend the postgresql image so supervisord runs postgresql using the config /var/lib/postgresql/12/main/postgresql.conf (/home/yellowtent/platformdata/postgresql/12/main/postgresql.conf)?

        Namely I suggest creating a symlink to the file:

        $ ln -s /var/lib/postgresql/12/main/postgresql.conf /etc/postgresql/12/main/postgresql.conf
        

        OR changing supervisord config file /etc/supervisor/conf.d/postgresql.conf:

        - command=/usr/lib/postgresql/12/bin/postmaster --config-file=/etc/postgresql/12/main/postgresql.conf
        + command=/usr/lib/postgresql/12/bin/postmaster --config-file=/var/lib/postgresql/12/main/postgresql.conf
        
        1 Reply Last reply Reply Quote 1
        • nebulon
          nebulon Staff last edited by

          I am not sure what exactly the setting will do, but generally allowing to tweak these things is not much supported as it is quite easy to break things and adjusting the values makes it impossible for us to test with then.

          Can you maybe explain the use-case on hand so we can see if it makes sense to possibly properly support that feature?

          marcusquinn vladimir.d 2 Replies Last reply Reply Quote 0
          • marcusquinn
            marcusquinn @nebulon last edited by

            @nebulon We can look into Nextcloud codebase optimisation with this, since it does suffer for speed at scale.

            We're not here for a long time - but we are here for a good time :)
            Jersey/UK
            Work & Ecommerce Advice: https://brandlight.org
            Personal & Software Tips: https://marcusquinn.com

            1 Reply Last reply Reply Quote 0
            • Moved from Support by  nebulon nebulon 
            • vladimir.d
              vladimir.d @nebulon last edited by

              @nebulon for the beginning we'd like to enable slow queries log to identify what causes postgresql taking almost 100% of CPU time all the time.

              1 Reply Last reply Reply Quote 0
              • girish
                girish Staff last edited by

                Ah, this is a good suggestion. I guess the intent here is that this will help us report slow queries upstream @vladimir-d ?

                1 Reply Last reply Reply Quote 1
                • Moved from Nextcloud by  girish girish 
                • girish
                  girish Staff last edited by

                  I have pushed this change now for 7.3.2. In the container, you can edit /run/postgresql/postgresql.conf . This won't persist but should help debugging.

                  1 Reply Last reply Reply Quote 2
                  • Topic has been marked as a question  girish girish 
                  • Topic has been marked as solved  girish girish 
                  • marcusquinn
                    marcusquinn last edited by

                    Sounds good. Yes, we're happy to help with query optimisation in apps and send feedback upstream. This is the quickest way we can do that. With some luck, we'll all end up with faster apps from this R&D too.

                    We're not here for a long time - but we are here for a good time :)
                    Jersey/UK
                    Work & Ecommerce Advice: https://brandlight.org
                    Personal & Software Tips: https://marcusquinn.com

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post
                    Powered by NodeBB