Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCKtx-0005mG-NS for pgsql-general@arkaria.postgresql.org; Fri, 05 Apr 2019 09:12:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hCKtw-0007K1-CY for pgsql-general@arkaria.postgresql.org; Fri, 05 Apr 2019 09:12:44 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCKtv-00078z-TI for pgsql-general@lists.postgresql.org; Fri, 05 Apr 2019 09:12:44 +0000 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCKtt-0006QI-5e for pgsql-general@lists.postgresql.org; Fri, 05 Apr 2019 09:12:43 +0000 Received: by mail-ot1-x32d.google.com with SMTP id o74so5003490ota.3 for ; Fri, 05 Apr 2019 02:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=iDd1hpDuscrBzIm0PfMFBO+WVlJUQTDTmyXOte6g5iw=; b=Yg1cFPjHFs61sbqMdh3lLtiLFSPrbx5Z4vfNXKU+szUziuoBhQxIWsWI4pMcuiVNaL +sNUA5S9D+h5FwCK0zn8Kx6hBcwg6o4V8Qw7JxaQ39ioSWkKu189SDUD//kQe85mxpNd Xdkv0SNwTmM7RjcTtlEeslXcssyQnuztwgg0AzholJdHhYQFC359jBJ+0rkk+doSzlrS j8AtyV/mFPkaiZk8XawMtLK0Y+QW3vDr/KfBGcqT211WjQvVrbw79bwsIQwEI1I7e6dm y5Rlw0LMjiovdclin4VGu9DGwE03scS8fM3zZV94HvTRvY09DEZD+LuOQTBFatnsOOS4 6ETw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=iDd1hpDuscrBzIm0PfMFBO+WVlJUQTDTmyXOte6g5iw=; b=c2iDLYS0zkRiD29RzgsALNqSAHhs+Sutkut2kQ5dwFn8tYa4OGZ2zZXXXfIPDo/rXS RqsTDsTjQnKi8KS9r4KF5Yuun0Ugz9EEJwvSaA4nqz5YjVj2T7OjsY+jwX57DsjnB5JX uqIVRqsxxmZvM0p9CwnhFnEM6weDJVVprZMF+Z1fjMnbo/A+Q+lL2lzqidseTM/HFZHc XvlafLoO8zawm+5c8Gecw2vFDlGD5+5XekrVEf+BlkREtAHcVVi2vtadbmoS0/hr9lO6 S3S7u0pplJxhFN1gw9hx1rQBmpjA0y2kJeD0v4fulnZ4V1Ub+vBH9IiICm88e35ous5x x64g== X-Gm-Message-State: APjAAAWMRz7W3qLrKolKMwTrVe0b9MXv+Q9cnxRoB2r5nX8MSGW/8XA2 K0G217WrIeMFbcJr5ePrrtdsey4RFO4= X-Google-Smtp-Source: APXvYqwHDeUf7PWSDm40t2JAmBx18I65N6DSDZAcX3Uwdjhl1leO7Znf6CP9lOHd6jGY9sQGRY5zpg== X-Received: by 2002:a9d:7a48:: with SMTP id z8mr230024otm.69.1554455559399; Fri, 05 Apr 2019 02:12:39 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id m21sm9149632otj.48.2019.04.05.02.12.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Apr 2019 02:12:38 -0700 (PDT) Subject: Re: Query much slower on 9.6.5 than on 9.3.5 To: pgsql-general@lists.postgresql.org References: From: Ron Message-ID: Date: Fri, 5 Apr 2019 04:12:37 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------E0A30FC3B563CCA004A350CF" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------E0A30FC3B563CCA004A350CF Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 4/5/19 3:43 AM, Rob Northcott wrote: > > I’ve had a couple of customers complaining of slow searches and doing some > testing last night it seems to be much slower on the live server than on > my test setup. > > It’s quite a messy query built up by the search code, with lots of joins > and subqueries. > > I’ve downloaded a backup of the customer’s live database to test, so I’m > running the same query on the same data, just two different servers. > > On the local test server (PSQL 9.3.5 running on an old Core2 Duo PC) it > takes around 200ms to run the query. > > On the live server (PSQL 9.6.5 on virtual server with 4 cores) it takes 20 > seconds to run the same query. > > Looking at the explain analyse, the two servers are using quite different > optimisation plans, but I can’t find any differences in the settings. > > Is there anything obvious I should look at that may be different between > 9.3 and 9.6? > > If not, would it help if I post the analyse output on here? (can we post > attachments to the group or should it just be text in the email?) > > Many thanks for any hints > I'll get the obvious first question out of the way, so that no one else has to ask: have you analyzed the 9.6 database?  If not, do that first. -- Angular momentum makes the world go 'round. --------------E0A30FC3B563CCA004A350CF Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 4/5/19 3:43 AM, Rob Northcott wrote:

I’ve had a couple of customers complaining of slow searches and doing some testing last night it seems to be much slower on the live server than on my test setup.

It’s quite a messy query built up by the search code, with lots of joins and subqueries.

I’ve downloaded a backup of the customer’s live database to test, so I’m running the same query on the same data, just two different servers.

On the local test server (PSQL 9.3.5 running on an old Core2 Duo PC) it takes around 200ms to run the query.

On the live server (PSQL 9.6.5 on virtual server with 4 cores) it takes 20 seconds to run the same query.

 

Looking at the explain analyse, the two servers are using quite different optimisation plans, but I can’t find any differences in the settings.

 

Is there anything obvious I should look at that may be different between 9.3 and 9.6?

 

If not, would it help if I post the analyse output on here? (can we post attachments to the group or should it just be text in the email?)

 

Many thanks for any hints


I'll get the obvious first question out of the way, so that no one else has to ask: have you analyzed the 9.6 database?  If not, do that first.

--
Angular momentum makes the world go 'round.
--------------E0A30FC3B563CCA004A350CF--