Обсуждение: Insert waiting for update?

Поиск
Список
Период
Сортировка

Insert waiting for update?

От
Ashish Karalkar
Дата:
<td style=3D"f=
ont: inherit;">Dear list members,I am having table with 4M rows.I a=
m trying to update all these rows with statementupdate mytable set =
mycolumn=3D0;At the same time there are insert happening on the tab=
le.but all these insert are in waiting mode. does update is locking=
 the table for insert?does insert and update confilict with each ot=
her?With regardsAshihs


       Save all your chat conversations. <a href=
=3D"http://in.rd.yahoo.com/tagline_webmessenger_3/*http://in.messenger.yaho=
o.com/webmessengerpromo.php">Find them online.

Re: Insert waiting for update?

От
Ashish Karalkar
Дата:


--- On Wed, 9/1/08, Ashish Karalkar <ashish_postgre@yahoo.co.in> wrote:
From: Ashish Karalkar <ashish_postgre@yahoo.co.in>
Subject: [GENERAL] Insert waiting for update?
To: "pggeneral" <pgsql-general@postgresql.org>
Cc: ashish.karalkar@netcore.co.in
Date: Wednesday, 9 January, 2008, 4:29 PM

Dear list members,
I am having table with 4M rows.
I am trying to update all these rows with statement

update mytable set mycolumn=0;

At the same time there are insert happening on the table.
but all these insert are in waiting mode.
does update is locking the table for insert?

does insert and update confilict with each other?
With regards
Ashihsh


For more details:

I have two tables master,child.
with child having fk to master.

Now that master table contains 4M rows . while I update them (Master table) the inserts are going into waiting mode on child table.


Update  acquired row exclusive lock on master table  , and the insert on child table acquired access share and share lock,row share on master.

Is this is what preventing for inserting records into child table, I mean is the row exclusive lock conflicting with the locks insert wants to hold?



With Regards
Ashish...










Save all your chat conversations. Find them online.


Why delete messages? Unlimited storage is just a click away.

Re: Insert waiting for update?

От
"Albe Laurenz"
Дата:
Ashish Karalkar wrote:
> I am having table with 4M rows.
> I am trying to update all these rows with statement
> 
> update mytable set mycolumn=0;
> 
> At the same time there are insert happening on the table.
> but all these insert are in waiting mode. 
> does update is locking the table for insert?
> 
> does insert and update confilict with each other?

Not normally, but it can happen.

You could

SELECT l.locktype, t.relname, l.pid, l.transactionid, l.mode, l.granted
FROM pg_catalog.pg_locks l LEFT OUTER JOIN
     pg_catalog.pg_class t ON l.relation = t.oid;

and

SELECT procpid, current_query FROM pg_stat_activity;

while the inserts hang. Maybe the result will indicate why.

Are there any triggers or rules defined?
What indexes are defined on the table?

Yours,
Laurenz Albe

Re: Insert waiting for update?

От
Ashish Karalkar
Дата:
<td style=3D"f=
ont: inherit;">Thanks for the replayI think you missed on second detail=
 mail :For more details:I have two tables maste=
r,child.with child having fk to master.Now
that master table contains 4M rows . while I update them (Master table)
the inserts are going into waiting mode on child table.Update&n=
bsp;
acquired row exclusive lock on master table  , and the insert on child
table acquired access share and share lock,row share on master. Is
this is what preventing for inserting records into child table, I mean
is the row exclusive lock conflicting with the locks insert(which is again =
row exclusive log) wants to
hold?With RegardsAshish...--- On Wed, 9/=
1/08, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:<bl=
ockquote style=3D"border-left: 2px solid rgb(16, 16, 255); margin-left: 5px=
; padding-left: 5px;">From: Albe Laurenz <laurenz.albe@wien.gv.at><br=
>Subject: Re: [GENERAL] Insert waiting for update?To: ashish_postgre@ya=
hoo.co.in, "pggeneral" <pgsql-general@postgresql.org>Cc: ashish.k=
aralkar@netcore.co.inDate: Wednesday, 9 January, 2008, 8:53 PM<=
pre>Ashish Karalkar wrote:> I am having table with 4M rows.> =
I am trying to update all these rows with statement> > update=
 mytable set mycolumn=3D0;> > At the same time there are inse=
rt happening on the table.> but all these insert are in waiting mode=
. > does update is locking the table for insert?> > do=
es insert and update confilict with each other?Not normally, but
 it can happen.You couldSELECT l.locktype, t.relname, l.pid=
, l.transactionid, l.mode, l.grantedFROM pg_catalog.pg_locks l LEFT OUT=
ER JOIN     pg_catalog.pg_class t ON l.relation =3D t.oid;and<b=
r>SELECT procpid, current_query FROM pg_stat_activity;while the=
 inserts hang. Maybe the result will indicate why.Are there any tri=
ggers or rules defined?What indexes are defined on the table?Yo=
urs,Laurenz Albe-------------------=
--------(end of broadcast)---------------------------TIP 9: In versions=
 below 8.0, the planner will ignore your desire to       choose an inde=
x scan if your joining column's datatypes do not       match</blo=
ckquote>


       Chat on a cool, new interface. No downloa=
d required. <a href=3D"http://in.rd.yahoo.com/tagline_webmessenger_10/*http=
://in.messenger.yahoo.com/webmessengerpromo.php">Click here.

Re: Insert waiting for update?

От
"Albe Laurenz"
Дата:
Ashish Karalkar wrote:
> I am having table with 4M rows.
> I am trying to update all these rows with statement
> 
> update mytable set mycolumn=0;
> 
> At the same time there are insert happening on the table.
> but all these insert are in waiting mode. 
> does update is locking the table for insert?
> 
> does insert and update confilict with each other?
> 
> For more details:
> 
> I have two tables master,child.
> with child having fk to master.
> 
> Now that master table contains 4M rows . while I update them 
> (Master table) the inserts are going into waiting mode on child table.
> 
> 
> Update  acquired row exclusive lock on master table  , and 
> the insert on child table acquired access share and share 
> lock,row share on master. 
> 
> Is this is what preventing for inserting records into child 
> table, I mean is the row exclusive lock conflicting with the 
> locks insert wants to hold?

Please post the table definitions including indexes and constraints.

Yours,
Laurenz Albe