Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VmWEG-0003Hv-B3 for pgsql-performance@arkaria.postgresql.org; Fri, 29 Nov 2013 22:08:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VmWEF-0001vq-QT for pgsql-performance@arkaria.postgresql.org; Fri, 29 Nov 2013 22:08:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VmWEE-0001vj-Mi for pgsql-performance@postgresql.org; Fri, 29 Nov 2013 22:08:02 +0000 Received: from dd20832.kasserver.com ([85.13.140.227]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VmWEB-0004cR-By for pgsql-performance@postgresql.org; Fri, 29 Nov 2013 22:08:02 +0000 Received: from [192.168.1.3] (p4FDC273A.dip0.t-ipconnect.de [79.220.39.58]) by dd20832.kasserver.com (Postfix) with ESMTPA id 1D8281CA0ADF for ; Fri, 29 Nov 2013 23:07:58 +0100 (CET) Message-ID: <5299103F.1040307@mueschelsoft.de> Date: Fri, 29 Nov 2013 23:07:59 +0100 From: Jan Michel User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: One query run twice in parallel results in huge performance decrease Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Dear all, I have a quite strange problem running an extensive query on geo data checking for crossing ways. I don't know if this is a postgres or postgis problem, but I hope you can help. Running one thread is no problem, it finishes within 10-15 minutes. Run two of those queries in parallel and they will not finish within 24 hours. It is definitely not a caching or I/O problem. First, the environment: Running on a large server (32 cores, 128 GB RAM, fast RAID disks) I tested psql 8.1 / 9.1 / 9.3 and postgis 1.5 and 2.1.0 on Debian 6 and OpenSuse 12.3. All behave similar. The pgsql server settings were optimized using pgtune, wal logging and autovacuum is off. I'm working on a set of databases, each 5-10 GB big filled with OSM geo data. I run many different queries, and I know the server can handle up to 8 parallel tasks without a decrease in performance compared to a single thread. Most data is kept in the cache and almost no read access to the disk needs to be done. Everything works well, despite one query, that runs on a table with ~ 1M entries. It searches for ways crossing each other: http://etherpad.netluchs.de/pgquery (The definition of the source table is included as well) Here is the explain analyze of the query: http://explain.depesz.com/s/fAcV As you can see, the row estimate is far off, but the runtime of 11 minutes is acceptable, I think. When I run a second instance of this query in a unrelated database on the same server, they take 100% CPU, no iowait and they do not finish even after more than a day. An explain done directly before executing the query shows a huge cost estimate and varying different plans: http://explain.depesz.com/s/XDR http://explain.depesz.com/s/SeG How can two queries have such a strong influence on each other? Especially when the host server could handle even ten queries without problems? And most important: What can I do? Thank you all in advance for your help! Jan -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance