Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1joFCM-0006b1-F4 for pgsql-general@arkaria.postgresql.org; Wed, 24 Jun 2020 23:52:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1joFCK-0000cU-OD for pgsql-general@arkaria.postgresql.org; Wed, 24 Jun 2020 23:52:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1joFCK-0000cN-Ds for pgsql-general@lists.postgresql.org; Wed, 24 Jun 2020 23:52:56 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1joFCI-0003w9-2A for pgsql-general@lists.postgresql.org; Wed, 24 Jun 2020 23:52:56 +0000 Received: by mail-pg1-x544.google.com with SMTP id d4so2332283pgk.4 for ; Wed, 24 Jun 2020 16:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:in-reply-to:message-id:date :mime-version; bh=vZ1lOPC5En589y+q/kEpgAebYBFjfTZpoEoAvCY2DR8=; b=aY7XVaGqbh6WK3y1K4srVQ8M8gNcDX+cRy6GbS92nv0bdciOW92tqEDeouHGQ5oNQN AHsTaP/DZ1Iz7oGe6Tduh5D3wyyGgsOl/vw5e51m67q3cz/5FAEKCjkBkiOlSsEeiqu3 snuuFJ45/2nN2q73A10dIbjyZe90FRy6qAGi2nFf4NpKY3qyzhT3OpayOQ6yJ7vDOoGg jW0KeKQSaUTjYp5CLOi/dsaD8gudfcYF1UiSAme3sbKQXSMCA/09r8/GReQ+jsY6rjxg gwQznc/kW8RZbwzNloT4aBuYPXN5YLs5SyP1cB0EO00Ztbc/NIEaYcNCCUIDg0jmwpQA VQ7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:subject :in-reply-to:message-id:date:mime-version; bh=vZ1lOPC5En589y+q/kEpgAebYBFjfTZpoEoAvCY2DR8=; b=cX6dwltXVrOE++K8qV0z5rOvzkiPSyuH57DKKogD8Mq7q7iOKOa5wMUBEAyn3CPM5/ 15XZmGTlv8BMTNkFlAsvsnWauJmDy2YjGqYVX4WGaevR7ax8nUWykYQghsSTNU9OdjT0 rQz2iiOIRYxtiFTqj8OREb/wV+NpxUYboKST/rRwyUlJ2uZ5/VC1BTstbaSVPMPGfM+N 8ZTrhHYvdhswD9usOfPiOuLVRESjCEBkONFrDoqQd2xYt2kjzfy/Mn1Ayig00BsVQ5HK nX+cdKQDaAQO6KtqHGVsW0sCft4rdLcVTq+WgVmvjRDRdfDA8KJhA8vDwBNDykCzUJ7w lYEg== X-Gm-Message-State: AOAM532ze2D2QxPPjt+DJRqkYbxq79vHICoVRQP0aoVRQDDm5iy9eniq 4KAsmJxacaGWjhYpF19w57+QHsDn X-Google-Smtp-Source: ABdhPJxzdJeqc40rE1BsgQj9J2orKZVKDM7rrIsmRJ529OM4EU64pfcWMMz1NRB5xp2cgkYqfE95/g== X-Received: by 2002:a63:d911:: with SMTP id r17mr12184649pgg.202.1593042771598; Wed, 24 Jun 2020 16:52:51 -0700 (PDT) Received: from tim-desktop (220-235-176-99.dyn.iinet.net.au. [220.235.176.99]) by smtp.gmail.com with ESMTPSA id b71sm11507284pfb.125.2020.06.24.16.52.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 16:52:50 -0700 (PDT) References: <20200624104736.GB417@hjp.at> <20200624193605.GB15882@hjp.at> User-agent: mu4e 1.5.3; emacs 27.0.91 From: Tim Cross To: pgsql-general@lists.postgresql.org Subject: Re: Persistent Connections In-reply-to: <20200624193605.GB15882@hjp.at> Message-ID: <87mu4sowbz.fsf@gmail.com> Date: Thu, 25 Jun 2020 09:52:48 +1000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter J. Holzer writes: > On 2020-06-24 13:55:00 -0400, Bee.Lists wrote: >> On Jun 24, 2020, at 6:47 AM, Peter J. Holzer wrote: > Does "I have 37 queries" mean you have seen 37 queries of this type in > some time window (e.g. the last day or hour) or does it mean you are > currently seeing 37 connections where the last query was of this type? > > If it's the latter, you very obviously have at least 37 (more likely > 37 + 5 = 42) connections. So you web app is configured to open dozens of > connections concurrently. You might want to look into that. > I just had another thought. Based on a VERY brief scan of the Sequel API, I suspect it uses a connection pool by default. So it is quite likely that the expectations on when the connections are closed is incorrect. It could easily be that the web app creates a connection pool as soon as it is started and keeps that pool open until either the web server is closed down or a pool timeout kicks in (some connection pools use a max lifetime setting for connections and will close a connection after that period, replacing it with a new connection). It is also quite likely that the Sequel GEM creates a connection pool with a default number of connections if not explicitly defined by the developer. This default could be close to or even exceed the number set for max connections within PG (especially as the OP has indicated it is very small). I have to say, I do hate ORMs. They always reduce the flexibility and power offered by SQL, tend to result in code where more processing is done in the client which would have been faster and more efficiently done by the SQL engine and hides details which make troubleshooting even harder. However, the worst issue is that it also results in developers not understanding the power of the underlying RDMS and encourages poor DB schema design. Those who support such technologies typically point to the benefits of database neutrality such systems can provide. In over 30 years of DB work, I have yet to see such neutrality actually work. It is a pipe dream. -- Tim Cross