Re: Fetch zero result rows when executing a query? - Mailing list pgsql-hackers

From Stephen R. van den Berg
Subject Re: Fetch zero result rows when executing a query?
Date
Msg-id 20150204111352.GB25788@cuci.nl
Whole thread Raw
In response to Fetch zero result rows when executing a query?  (Shay Rojansky <roji@roji.org>)
Responses Re: Fetch zero result rows when executing a query?
List pgsql-hackers
Shay Rojansky wrote:
>I'm working on the Npgsql, the .NET driver for PostgreSQL, and am trying to
>find a way to execute a query but without fetching any rows. The Execute
>message has a maximum result-row count, but zero is documented to mean
>"fetch all rows".

>The use case would be sending a query which might modify or might not (e.g.
>UPDATE), but we know that the user is uninterested in any result row.

>My current workaround is to specify maxrows=1, was wondering if I missed a
>better alternative.

If you know beforehand the query generates at most one row, then
specifying maxrows=0 is best.
If you know beforehand the query might generate more than one row (SELECT)
yet you also know that you are not interested in those, then maxrows=1
is best; then again, modifying the query to include a LIMIT 1 is even
better, in which case maxrows can be zero again.
maxrows=1 for UPDATE/DELETE/INSERT does not make sense, use maxrows=0.
-- 
Stephen.



pgsql-hackers by date:

Previous
From: "Stephen R. van den Berg"
Date:
Subject: Re: Table description in the data file (Re: pg_rawdump)
Next
From: "Stephen R. van den Berg"
Date:
Subject: Re: Fetch zero result rows when executing a query?