From: | Steve Midgley <science(at)misuse(dot)org> |
---|---|
To: | Vijaykumar Jain <vijaykumarjain(dot)github(at)gmail(dot)com> |
Cc: | Avadhut Narayan Joshi <AJoshi7(at)sensiaglobal(dot)com>, pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Equivalent of InternalRowsAffected in NonExecuteQuery for PostgreSQL |
Date: | 2021-07-29 19:43:02 |
Message-ID: | CAJexoS+Lj1HCRic=adnyswqJ5FCky4nXUtPBXiJODHwZdvcReA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, Jul 29, 2021 at 5:37 AM Vijaykumar Jain <
vijaykumarjain(dot)github(at)gmail(dot)com> wrote:
>
>
> On Thu, Jul 29, 2021, 6:01 PM Avadhut Narayan Joshi <
> AJoshi7(at)sensiaglobal(dot)com> wrote:
>
>> Hello Vijaykumar ,
>>
>>
>>
>> For SQL Server , when we execute queries using ExecuteNonQuery ,
>> InternalRowsAffected is set by default .
>>
>> Using diagnostics we have to collect and return explicitly for further
>> work flow .
>>
>>
>>
>> So is there any out-of-box equivalent in PostgreSQL
>>
>
> OK, honestly I do not know much about sql server.
> You can run explain, on the query to get an estimated rows that would be
> touched at each node layer.
> explain analyze, would give estimated and real number of rows touched at
> each node layer.
> There are stats updated in pg_stat_all_tables catalog for the relevant
> table for ins, upd, del etc but that is cumulative at the db layer, not
> sure if that can be useful at per query layer.
> I think in that case, someone else would chime in with more exp.
>
> There's a fairly robust discussion of this over on StackOverflow:
https://stackoverflow.com/questions/13647925/getting-affected-rows-by-update-statement-in-raw-plpgsql
My recollection (hazy) is that for my ORM wrapper of choice (ActiveRecord
for Ruby), the AR Pg driver returns the number of rows affected and I just
relied on that. (cf
https://stackoverflow.com/questions/27552542/affected-rows-for-activerecordbase-connection-execute
).
I hope this input is helpful,
Steve
From | Date | Subject | |
---|---|---|---|
Next Message | Rockdale Green | 2021-08-03 15:40:03 | How to generate the order if you know the next item for each item? |
Previous Message | Vijaykumar Jain | 2021-07-29 12:37:17 | Re: Equivalent of InternalRowsAffected in NonExecuteQuery for PostgreSQL |