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 1u1h8S-006Z1Z-VL for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 07:43:12 +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 1u1h8R-00DAa2-D8 for pgsql-general@arkaria.postgresql.org; Mon, 07 Apr 2025 07:43:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u0fQQ-00GwFg-TP for pgsql-general@lists.postgresql.org; Fri, 04 Apr 2025 11:41:30 +0000 Received: from mail-vk1-xa29.google.com ([2607:f8b0:4864:20::a29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u0fQO-002uM5-2n for pgsql-general@lists.postgresql.org; Fri, 04 Apr 2025 11:41:30 +0000 Received: by mail-vk1-xa29.google.com with SMTP id 71dfb90a1353d-524168b16d3so1767566e0c.0 for ; Fri, 04 Apr 2025 04:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743766888; x=1744371688; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bxrgFw4AtJ1rqxxhTOP9EnkOWOyXc0FcmsebFJLrHxg=; b=Z5Xldu3EnT5y/tEr8NE/OOL0U8XYAUtHPU9YJXefCvE3AWLt+YDaJyoZYWd07SGsMv EIgd+6v7qrL/U8Zy6HhYS97Ydsz0fTYxHKo99tKkJfjAraS5rogQ3uBvOqxnOikWvrWm HPLvrYRk79ElsVBEuz2rKNyDXiwO5ZVct0EG11CMN9nvDFnohHE3pL04H5KSrE1VjwVj 0fzhui7G1ip9PXSyBkzl5RZknpfuB0U9vUoImLBIJ0pHyUkho5vlEwKDJcw5BfqmFT4W nzPyH5Oh9mIdGbP7OSxY1syLIqdWV5Ky39Vi6zw6FQD65Hg273DTfvxhSHwrvekFFZMP y+dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743766888; x=1744371688; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bxrgFw4AtJ1rqxxhTOP9EnkOWOyXc0FcmsebFJLrHxg=; b=I8N4G5Ip/eAfkLQIEb7H2H4AtCHR4BTMR7Uxa8vAVcduBpjyfJeOmY+qqyAUfrW8Mr ufDbQApct9gxrECRJ8cx8mBZVXLl5TaBofvElkAiU0C87thAW4FuF5oKl8rfvc6C4Eq9 u44A4hKam0qt0haInBKp6S7RSfave42FI8CVhIQPmYyYdTUJ1ESgtD+KGjg3wHqIrWhH ueZhAwvIDbBLSIDfZgxdULyRqmt6wmJMz1cB1EAkpGrN1EIs0duP3IHBI41lAAbcTCEE QLG28Aq2tYORPZFK7InIyM17OAnKH83kgNPvaWAJ67votsGYOnhI4FSfP44P6YC7L1s+ 8Arw== X-Forwarded-Encrypted: i=1; AJvYcCW9wduXYsdAKFKShdAIL3VhADOsRPi/6rYNAQiR9iyI6TXVkZHRyFvI5yfzNJ9vpYRvAmV1b2na2IGVJiCx@lists.postgresql.org X-Gm-Message-State: AOJu0YzkB3+isIqGt3Sg/j5ZEIkDL5haPhutq/qDlSZMPbpm4C5MItK6 NvsQUPgAgWGF9ymin84B83O0I+1vXtijdz+Uuyc/meyiMf678jxzPsm/LQXGKBGn1UzjPhl4ehG n+qMd1ZAltL4FJsMQQ8xMKCtdFeE= X-Gm-Gg: ASbGncv8kRZwKnY9WFuZyVpFNUw1/vB0dv65gQBhs0n8KUy6ckrKEqk52ydJRX0WDXb 08k7SrXV5DTpzFDYnOouivB24SqTl6x6uP58h4VkzL3QCdFYySaM8FID6l+MN4SxT0crxpzD0i6 0YBJ9rdiU9+e8sfiNq6a6J2NDs X-Google-Smtp-Source: AGHT+IEPF3so/GDa3IUaeJ1a/37AOsKU6IR7W7QmpzFlWHORfaaK9iptUMNTIDih8RdLrfsc0daAnWYPypFLE/Ki8gM= X-Received: by 2002:a05:6122:31a6:b0:518:91b3:5e37 with SMTP id 71dfb90a1353d-52765c650c4mr1416039e0c.5.1743766887928; Fri, 04 Apr 2025 04:41:27 -0700 (PDT) MIME-Version: 1.0 References: <140214eb-a8ce-4285-afdd-7770c5a9d274@manitou-mail.org> <1335670.1736193981@sss.pgh.pa.us> In-Reply-To: <1335670.1736193981@sss.pgh.pa.us> From: Stijn Sanders Date: Fri, 4 Apr 2025 13:41:17 +0200 X-Gm-Features: ATxdqUFYsace-xH4x5IUoN4CYjPpDFLsVF91n6OEOsdujfmY490XooFSAhOk4Mw Message-ID: Subject: Re: Will PQsetSingleRowMode get me results faster? To: Tom Lane Cc: Daniel Verite , pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jan 6, 2025 at 9:06=E2=80=AFPM Tom Lane wrote: > So in principle, you might get best results by defining your query > with DECLARE CURSOR and then using PQsetSingleRowMode on the FETCH. > But it'd really depend on the particular query whether this gives > any benefit. That's a really nice suggestion, and it took me some time to set up a suitable test environment to see if it would work, but using separate PQsendquery/PQexec calls for: start transaction read only declare cr1 no scroll cursor for select (and the rest of my query) fetch next in cr1 it seems like the fetch instruction still takes about as much time as the full 'normal' select would, I tried a few different queries, but I'm still suspecting PostgreSQL's internals is waiting for the data to all 'be ready' before it can send any data over, even if these PQgetResult's for each fetch will have a PQntuples of 1. (I even tried with "fetch 8", and PQntuples neatly serves 8 at a time, but still after about the same time PQsendquery(,'select... would take) Or could there still be something that I'm doing that prevents 'firehosing'= ?