From: | "Stephen R(dot) van den Berg" <srb(at)cuci(dot)nl> |
---|---|
To: | Shay Rojansky <roji(at)roji(dot)org> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Fetch zero result rows when executing a query? |
Date: | 2015-02-04 11:13:52 |
Message-ID: | 20150204111352.GB25788@cuci.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen R. van den Berg | 2015-02-04 11:17:23 | Re: Fetch zero result rows when executing a query? |
Previous Message | Stephen R. van den Berg | 2015-02-04 11:02:41 | Re: Table description in the data file (Re: pg_rawdump) |