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 1fR0Mg-0006XL-QJ for pgsql-general@arkaria.postgresql.org; Thu, 07 Jun 2018 19:14:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fR0Mf-00030u-8R for pgsql-general@arkaria.postgresql.org; Thu, 07 Jun 2018 19:14:29 +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 1fR0Mf-00030j-0M for pgsql-general@lists.postgresql.org; Thu, 07 Jun 2018 19:14:29 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fR0Mb-0007pG-Vk for pgsql-general@postgresql.org; Thu, 07 Jun 2018 19:14:28 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B680921B18; Thu, 7 Jun 2018 15:14:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 07 Jun 2018 15:14:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=LNoIegD4npgmXECLFqegi99gZ3McJ Fs+8sDHCRfB0N0=; b=Q26rPPW8QTcRi2/gdWkBcSlrloD0GxmTChe8bPECQITuH xXtZ77adn+shyvqeNiXb4vHdnIfWCZ6KeoXFrFzXxGTwpzX+/Ydu2dpx72o6xKiw w/IT/tkF6XHKqyJNmeUp0uWyM1E3wqSNaf5vhd/V7n2zVR1z9r9PIFfctVU3y881 SiKvnF3118b9nsCKWm9Ao5C/Qs40bIxX02Aoqpl8Gf3ej101ZllnUXWStAFnwPql nGbyQlyQBIKmVVVkgOW1LOQaiPAZj4ZM5CkJ+RU7rnfRhayz2NkdLInqs9c9zTjV b73d2KAv6etFfYvSFW+SMV/BNh4RYSeezyWoY/YYw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=LNoIeg D4npgmXECLFqegi99gZ3McJFs+8sDHCRfB0N0=; b=LdxrzZHVX+Z0LRjYoZnRFj ZSKOpXSj0usukrVySvadUL1xo1PNp3uqnaWZc6wu5gCgaU4BbMK3gnI6/1v4NSI1 VaOIECAOK9KcjjDr+aJYf/v83OJKgXuicf2rkwCcIHQ8oV1CfTw6mKEH6ZG/T9+w TbpbVFLUSwUOSAg4OxCMf0Y98PnOG2y5SY/nlMX4Uk+IgTkD0n68QJl73ekYiON1 Q4jm5hktw1SnX24KT8Ac+5QPV7f5YjLBeSUhQP2UWNv9uQHDaAZM8PyBFoPcFznt Jvf8e/D9NEzei0SJt6R5yCQg1/9O4yH+EJTGigP83c1Nf+Oe4osSMoq4eeIr1vvQ == X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.159.209]) by mail.messagingengine.com (Postfix) with ESMTPA id F18B110262; Thu, 7 Jun 2018 15:14:23 -0400 (EDT) Subject: Re: Query hitting empty tables taking 48 minutes To: Robert Creager Cc: pgsql-general@postgresql.org, Robert Creager References: <186A2F70-5953-4FE4-9586-BF3F114AF1CC@logicalchaos.org> From: Adrian Klaver Message-ID: Date: Thu, 7 Jun 2018 12:14:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 06/07/2018 11:55 AM, Robert Creager wrote: > > >> On Jun 7, 2018, at 12:40 PM, Adrian Klaver > > wrote: >> >> On 06/07/2018 11:17 AM, Robert Creager wrote: >>> I have a system running FreeBSD 11.1-STABLE, PostgreSQL 9.6.8,Java >>> OpenJDK 1.8.0_131, jdbc 9.3-1104-jdbc41 which is exhibiting very >>> bizarre behavior.  A query is executing against a couple of tables >>> that have 1 and 0 records in them.  ds3.job_entry has 0 rows, >>> ds3.blob has 1 row.   If I execute the query manually via command >>> line, it executes fine.   There are no other active queries, no >>> locks.  The system is idle, in our Dev Test group, so I can leave it >>> this way for a bit of time.  The general software setup is in >>> production and I’ve seen nothing like this before.  Even a system >>> with 300M ds3.blob entries executes this query fine. >> >> So I am assuming the problem query is being run through Java/jdbc, >> correct? > > Yes. > >> >> There is also the below in the log: >> >> " ... execute fetch from S_2037436/C_2037437 …" > > So, that means nothing to me.  Something to you? Just that the query being run from the code is going through a different path then the version you ran at the command line. Just trying to get to apples to apples if possible. > >> >> My guess is that we will need to see the Java code that sets up and >> runs the query. Is that possible? > > OMG, you had to ask ;-)  Not really, for two reasons.  It’s an actual > shipping product, and I’d have to send you so much code to get from the > source of the query down through the execute…. Now, the execute, on it’s > own, is below.  m_statement is a java.sql.PreparedStatement.  Keep in > mind this code is literally executing millions of times a day on a busy > system.  Except for this special snowflake system... I am not a Java programmer(hence the 'we' in my previous post), so someone who is will need to comment on the below. Though I have to believe the: m_statement.setFetchSize( 10000 ); has got to do with: " ... execute fetch from S_2037436/C_2037437 …" In your OP you said the tables involved have 1 and 0 rows in them. Is that from count(*) on each table? Or is it for for job_id = 'b51357cd-e07a-4c87-a50b-999c347a5c71'? > > private Executor executeQuery() > { >     final MonitoredWork monitoredWork = new MonitoredWork( > > StackTraceLogging.NONE, m_readableSql.getLogMessagePreExecution() ); >     try >     { >         m_closeTransactionUponClose = ( null == m_transactionNumber ); >         m_statement.setFetchSize( 10000 ); >         final Duration duration = new Duration(); >         m_resultSet = m_statement.executeQuery(); >         m_readableSql.log( duration, null ); >         return this; >     } >     catch ( final SQLException ex ) >     { >         throw new DaoException( >                 "Failed to execute: > " + m_readableSql.getLogMessagePreExecution(), >                 ex ); >     } >     finally >     { >         monitoredWork.completed(); >     } > } > >> >> -- >> Adrian Klaver >> adrian.klaver@aklaver.com > -- Adrian Klaver adrian.klaver@aklaver.com