Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fT4HW-000123-N1 for pgsql-general@arkaria.postgresql.org; Wed, 13 Jun 2018 11:49:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fT4HT-0002Tc-L1 for pgsql-general@arkaria.postgresql.org; Wed, 13 Jun 2018 11:49:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fT4DX-0003sS-W8 for pgsql-general@lists.postgresql.org; Wed, 13 Jun 2018 11:45:36 +0000 Received: from mout.kundenserver.de ([212.227.126.187]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fT4DT-0004SG-54 for pgsql-general@lists.postgresql.org; Wed, 13 Jun 2018 11:45:34 +0000 Received: from [10.8.0.146] ([185.40.248.10]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPSA (Nemesis) id 0MHfXI-1fWNbJ32XU-003OKf for ; Wed, 13 Jun 2018 13:45:29 +0200 Subject: Re: First query on each connection is too slow To: pgsql-general@lists.postgresql.org Newsgroups: gmane.comp.db.postgresql.general References: From: Thomas Kellerer Message-ID: Date: Wed, 13 Jun 2018 13:45:29 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:LC7STFfHMfRqJJOM8LlnTpo7/fqs0lJiXF0GbsBvdshOwtRVF2p CBVw6i2v3iIZUK4oKvpHzlvlYkvNmif3rLnHEHIW1IvFM4d/77aP6OKPjzMY3sh5+yWpfiK y+i+/uhwIceECsXteXp8NA7wVj7EXYDwSAg7QW++El8wR3eJ47fquQwwQR0w5TBrbl2xoV8 Q9qMUMK56T9fUhrJMc1yw== X-UI-Out-Filterresults: notjunk:1;V01:K0:emaP2czLtHk=:8Ebzd/n3vbGFFgaZ05aJ9G OOumf8sNZWBRfe1oUY9sLd4Fovc5JC8ks9J+PhSvb+zmDw25bdVOcdygGoqT+AIoxtZdByKUx 5iFhkZn7Bh/kvnjpltAQbWO9h9MztViXx0A+6NnyyYco8vlik+eqvvaSTttrdeFioMId445LJ 6k1pJPJ8v5N5JGCqPwtDng/j5wTStijzhYe+Z1HhWv/QIVuK0BbTFIpthfsf2Rvcb4S4SEBKo Td0KnHcyxWdPFaKaFhVZ8I+ZkHxQ79Bn+maUAVuKW7AgKEBIFtyzOqeFrcn8uTSeGpv1N7jqB V7fsSh0CqZa48ntCus0h+p7/3kFDqKku8KnBQv9Ybpr8H5n4I76kHxNwR4OMf4Jo3h7JR4UH5 PiDkp0lwQJAwGCQg2aznyfQDXj8KrpXyOnIltGofZXMmJ+rqYXTKlfzW5MtCwaMlqWe/gFYtE eZHhHW2bUR785GY3D00p/mHF0+bTtnij/BMiPc/qiNgukf8ZMA0FatqJJPXH0y13sIoL2CVVW aJot8bHLEFQQqLh68MHU3z/ui+jzS+nYgLbgMFIyWJyR2ZULM3vQXEe5vRseFAnLbRAgwwCl7 v+K4QxfKMpGoitjxTEckUjtMwl/N7F8yJlkI2LG13AodFPwMWOo3Om5uR9vFJLBXfrGlbAM4K uLi1ZWbQIq4fvBSqvK8SpQkSC+IqOXb9kGgKRERW+HOJVZAm5RVs9zYGZFik1HDLNxH/1Rv8n QRAce2k9ZWWvxVvU List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Vadim Nevorotin schrieb am 13.06.2018 um 11:55: > I have a very strange problem. I'm using PostgreSQL 9.6 with PostGIS > 2.3 (both from Debian Strecth repos) to store DB for OSM server (but > actually it doesn't matter). And I've noticed, that on each new > connection to DB first query is much slower (10x) than all others. > E.g.: > > If I run others instances of psql in parallel, when the first is > active - they has absolutely the same problem. In one instance of > psql query is fast (if it's not the first query), in others - first > query is slow, but all others is fast. Do you have many(!) tables and schemas? Caching of schema information is done per connection, so maybe the lookup of the table in the system catalogs is what is taking so much time. But I think you would need thousands of schemas with thousands of tables each schema in order to notice an impact there.