Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qMWam-002bqp-Ah for pgsql-jdbc@arkaria.postgresql.org; Thu, 20 Jul 2023 16:33:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qMWak-00Br0I-QD for pgsql-jdbc@arkaria.postgresql.org; Thu, 20 Jul 2023 16:33:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qMWak-00Br0A-GW for pgsql-jdbc@lists.postgresql.org; Thu, 20 Jul 2023 16:33:26 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qMWag-000gNp-Kt for pgsql-jdbc@lists.postgresql.org; Thu, 20 Jul 2023 16:33:25 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4fdd515cebcso1530594e87.0 for ; Thu, 20 Jul 2023 09:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689870802; x=1690475602; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=pdnVcgM34/WwDH6v99J9d0DC8byk7mZmlxGDoDjl1ys=; b=W/vVs5xECgpvyR/x6jzh2FmExc0LqFC8BoE9u/ABbtLZeCkhr1E5Hrmyk9D3prPmtv StrerYKQEu9oN4EIgkoDBMRmMiplxvwdmGNG3ystpUoA7f8zliHkXOHqgy0Gqq3bznso LwSv7LbTJ9VQBPhwtOsDu/uvmQbSVt7l1qeQRPo63BcMXfgXnjKpkplEn5qKYVG7sa+i s5B/XeQ0mS/5Ic1FsUx86/LKOXVT3AVtW1C6TH/oMeNqcGFQ+LboxULaWsCsPpQ6JVQe DLPFMFuUS/9IG6N4OuE4kpWTyloKRM+TESlilhlca2aXzM1jUiYa7YjY+bSlfco0eU4X x2Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689870802; x=1690475602; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=pdnVcgM34/WwDH6v99J9d0DC8byk7mZmlxGDoDjl1ys=; b=fzCQCDAoq1twTunSHB3pu/05yNcY3hveSEkHBwhZJrtD83T65uICJjA5pshwoWkTw3 hHXI4WWgQy/mKmrAFGijKPbO+kLIX4amKHccmUJeEz+48hMj4fVnuoEWs0aszROzND1h PB+YNQ3sHHm+MbWXLpNBYiM7g7vDRnBJW4Jrjq7z6biQMf6mAhUnJ2AUsAuYLkcVEPlK 6sz5Pw51wC2nL1KEN6DGf3eT/7MmpWHAOqYfd+eVS8Bdkex380OcEGEWaL6jTAQz3xQJ 0EmhrWS+TyCWngd5b1XnQVxE7m0hjpj6kObv84yitl578+8H9c/DOoSPTy8dbtSErUHk GvRQ== X-Gm-Message-State: ABy/qLYzm/lrxH5SnYY5BirxIy+s08l3iL42AZTT1eNvSlk27mZBAwUW 32lHjHfkZaiiHrwYI2rj7TAOxK3tgwyyGhDffnYe+VMHaxw= X-Google-Smtp-Source: APBJJlHhUJHlvuSQr1Lad7vm0IBlHkYqddKAKWejkQl61L+XEAeWU9AOaHCHRXzJIxmeZFbulpl0wO/eIuNnWR8OCQ8= X-Received: by 2002:ac2:5b8d:0:b0:4fb:835a:8486 with SMTP id o13-20020ac25b8d000000b004fb835a8486mr2393465lfn.32.1689870801696; Thu, 20 Jul 2023 09:33:21 -0700 (PDT) MIME-Version: 1.0 From: Blake McBride Date: Thu, 20 Jul 2023 11:33:10 -0500 Message-ID: Subject: Executing the same query multiple times gets slow To: pgsql-jdbc@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000d9fc7a0600edb408" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000d9fc7a0600edb408 Content-Type: text/plain; charset="UTF-8" Greetings, I have a complex query that returns about 5,000 records and only a few columns. If I run it in psql repeatedly, it's always fast. If I run it through JDBC it runs fast at first but then it gets real slow (> 50 seconds). I can't understand why it would get slow after 30 runs of the exact same query. I am running: Linux / 64GB RAM PostgreSQL 15.1 postgresql-42.5.4.jar I am using a prepared statement but a new one each time even though it is the same query (there are reasons for this). I found the line that's having the delay is: pstat.executeQuery(); where: PreparedStatement pstat; Sure appreciate any pointers! Thanks. Blake --000000000000d9fc7a0600edb408 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Greetings,

I have a complex query that = returns about 5,000 records and only a few columns.=C2=A0 If I run it in ps= ql repeatedly, it's always fast.=C2=A0 If I run it through=C2=A0JDBC it= runs fast at first but then it gets real slow (> 50 seconds).=C2=A0 I c= an't understand why it would get slow after 30 runs of the exact same q= uery.

I am running:

Linux= / 64GB RAM
PostgreSQL 15.1
postgresql-42.5.4.jar

I am using a prepared statement but a new one each = time even though it is the same query (there are reasons=C2=A0for this).

I found the line that's having the delay is:=C2= =A0 pstat.executeQuery();

where:=C2=A0 PreparedSta= tement pstat;

Sure appreciate any pointers!
<= div>
Thanks.

Blake

--000000000000d9fc7a0600edb408--