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 1ho6vW-0005QS-NP for pgsql-interfaces@arkaria.postgresql.org; Thu, 18 Jul 2019 13:58: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 1ho6vV-00087H-6I for pgsql-interfaces@arkaria.postgresql.org; Thu, 18 Jul 2019 13:58: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_SHA1:256) (Exim 4.89) (envelope-from ) id 1ho6vU-000879-Sr for pgsql-interfaces@lists.postgresql.org; Thu, 18 Jul 2019 13:58:29 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ho6vS-0006p3-1B for pgsql-interfaces@postgresql.org; Thu, 18 Jul 2019 13:58:28 +0000 Received: by mail-lf1-x144.google.com with SMTP id s19so19286209lfb.9 for ; Thu, 18 Jul 2019 06:58:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=3+O5RjLldK6uGvQiEiOq6BklfRfGB0HTaql1K2HyZVI=; b=DKqV8fZCaCIkMff9GVciTOkFv2QW+sAAzj19RJ3x4IiZtGv7hTNH6Q1c72KXO+hhIM Ut9Mg/X3Wnuy9GA91b3IA6ssQrWBzUPFifvNXQI5fQVqXlLn6dVhCVKAwXDN6AbDyZeq N9Ibic02ozO4gLIxLRDaRR1wAWKY39xcm5m74G2sFzZJtBg9k/9viCCu7eTKygNNklQS bFG91d1qG19y/MHS82fdYY5IKxibisnbZVLAhfarfOhU/87eRQuxNP1ZvVya9PpRd8iz TFUt4ZlvM9Kzc+HQU1ppkVEtQvdo+meJY8EvhQlZpaW3EnGeM8d8eZHes64/wYLW49b3 zGUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=3+O5RjLldK6uGvQiEiOq6BklfRfGB0HTaql1K2HyZVI=; b=k5XOds0QwmED45l+qlS95reJCEBYD94Yq0C1dNCHibA60qH22An8oRc+FoSnnmNgYy FSWOQvrYo5ScJjbNlnWymQ1ncw3GEVLPE2VsHUvstypte6quDno1PWHlaCLfjNY1ImgS 0WV4SdCQlolfvRD5ilo3heITz9VZA8W0Uapg8ZtVcAH5ZthbKkDLeuvh2ChsuB7gW1eO 0+Y9PSCI9hhDtCN07yiFNRG8+jBAqYeqoIZT2+WKMqOT9ax6w/vT/662mzpFQSyAa6Rz DjDPZnu5JAZy4yIbH6xzxwBOsrFz6fixY+qFpv1Ln3ub4+pBBfqHQcNDDqOvOYCeeb+M jjuA== X-Gm-Message-State: APjAAAUyoAGQULHoUhTodEIAoxiWkHjB82NwdPDmCsKz17WyBvtger5A IPP35KLLbWNX424TrqXLWPuT/FGnGVdH26+QQbnACzLG X-Google-Smtp-Source: APXvYqxmU/3bsZeQlDo0mT6mtMXIiB6s/6aoynAhXtItEEjvUyXsjrQdHVug2qYQUKEQHnvBRX5Jnen2EfB7mbg6B0k= X-Received: by 2002:a19:c6d4:: with SMTP id w203mr21306136lff.135.1563458301613; Thu, 18 Jul 2019 06:58:21 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?B?THVrw6HFoSBTb2JvdGth?= Date: Thu, 18 Jul 2019 15:57:55 +0200 Message-ID: Subject: Using COPY command in pqlib To: pgsql-interfaces@postgresql.org Content-Type: multipart/mixed; boundary="000000000000b0b57a058df500dc" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000b0b57a058df500dc Content-Type: multipart/alternative; boundary="000000000000b0b578058df500da" --000000000000b0b578058df500da Content-Type: text/plain; charset="UTF-8" Hi guys, I would like to ask you on correct way how to use pqlib for copying data. We tried to do it according documentation but some problems occurred. We have a multi-threaded application, all threads hold own non-blocking connection into the remote database. Each thread is collecting data and when a buffer is filled they copy data to remote DB as quick as possible. Copying can run several times per minute. The postgresql related part of thread main loop is briefly shown in attached file main.c. Most of the time copying works well but big delay sometimes occurred. I captured pcap (see https://ibb.co/2MhmSTZ) and the delay is between getting PGRES_COPY_IN from PQresultStatus function and pushing data. But I am sure that commands PQputCopyData and PQputCopyEnd are called immediately after client gets PQexec. What am I missing? Is there some other command which we should use? We are using PostgreSQL 9.6 (PostgreSQL 9.6.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit). Best regards, Lukas --000000000000b0b578058df500da Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi guys,

I would like to ask you on correct way how= to use pqlib for copying data. We tried to do it according documentation b= ut some problems occurred.

We have a multi-threaded application, all= threads hold own non-blocking connection into the remote database. Each th= read is collecting data and when a buffer is filled they copy data to remot= e DB as quick as possible. Copying can run several times per minute. The po= stgresql related part of thread main loop is briefly shown in attached file= main.c.

Most of the time copying works well but big delay sometimes= occurred. I captured pcap (see https://= ibb.co/2MhmSTZ) and the delay is between getting PGRES_COPY_IN from PQr= esultStatus function and pushing data. But I am sure that commands PQputCop= yData and PQputCopyEnd are called immediately after client gets PQexec.
=
What am I missing? Is there some other command which we should use?
=
We are using PostgreSQL 9.6 (PostgreSQL 9.6.10 on x86_64-pc-linux-gnu, = compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit).

Be= st regards,
Lukas
--000000000000b0b578058df500da-- --000000000000b0b57a058df500dc Content-Type: text/x-csrc; charset="US-ASCII"; name="main.c" Content-Disposition: attachment; filename="main.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_jy8qncs30 Zm9yICg7OykgewoKCS8vIGNvbGxlY3RpbmcgZGF0YSB1bnRpbCBidWZmZXIgaXMgZmlsbGVkCgoJ UEdyZXN1bHQqIHJlczsKCgkvLyB3YWl0IHVudGlsIGNvbm5lY3Rpb24gaXMgcmVhZHkKCXdoaWxl ICgocmVzID0gUFFnZXRSZXN1bHQoY29ubikpICE9IDApIHsKCQljb25zdCBFeGVjU3RhdHVzVHlw ZSBzID0gUFFyZXN1bHRTdGF0dXMocmVzKTsKCQkvLyBlcnJvcnMgaGFuZGxpbmcKCQlQUWNsZWFy KHJlcyk7CgkJdXNsZWVwKDEwMDApOwoJfQoKCS8vIGVzdGFibGlzaGVkIENPUFkKCXJlcyA9IFBR ZXhlYyhjb25uLCBxdWVyeSk7CglzdGF0dXMgPSBQUXJlc3VsdFN0YXR1cyhyZXMpOwoJaWYgKHN0 YXR1cyA9PSBQR1JFU19DT1BZX0lOKSB7CgoJCS8vIHNlbmQgZGF0YQoJCWNvbnN0IGludCBjb3B5 X3Jlc3VsdCA9IFBRcHV0Q29weURhdGEoY29ubiwgYnVmZmVyLCBzaXplKTsKCQlpZiAocmVzID09 IDEpIHsKCQkJY29uc3QgaW50IGNvcHlfZW5kX3Jlc3VsdCA9IFBRcHV0Q29weUVuZChjb25uLCBO VUxMKTsKCQkJLy8gZXJyb3JzIGhhbmRsaW5nCgkJfQoJfQoKCVBRY2xlYXIocmVzKTsKfQo= --000000000000b0b57a058df500dc--