From: Jim C. Nasby <jnasby@pervasive.com>
To: Tsirkin Evgeny <tsurkin@mail.jct.ac.il>
Cc: Bruno Wolff III <bruno@wolff.to>
Cc: pgsql-admin@postgresql.org
Subject: Re: preventing deadlocks
Date: Thu, 5 Jan 2006 15:02:10 -0600
Message-ID: <20060105210210.GX43311@pervasive.com> (raw)
In-Reply-To: <43BCDE94.3030902@mail.jct.ac.il>
References: <43B10E07.7010503@mail.jct.ac.il>
<20051228202607.GA5194@wolff.to>
<Pine.GSO.4.58_heb2.09.0601021131080.10840@ketubot.jct.ac.il>
<20060104003001.GY82560@pervasive.com>
<Pine.GSO.4.58_heb2.09.0601041035520.7100@ketubot.jct.ac.il>
<20060105065747.GA17322@wolff.to>
<43BCDA17.6070806@mail.jct.ac.il>
<20060105084030.GA32572@wolff.to>
<43BCDE94.3030902@mail.jct.ac.il>
I'm not really sure What Bruno answered that you didn't ask, but I'll
mention that anything you try here other than doing inserts and deletes
from your trigger is flat out going to perform poorly due to locking.
Plus, as you discovered, deadlocking will be a major issue, unless you
establish a table-level lock on your count table at the begining of the
transaction.
Personally, I'd just put the effort into setting up the insert/delete
stuff and a means to periodically roll that info up into a summary
table. I know that this has come up in the past, so you can probably
find someone else who's already done this and might be able to provide
you with code. Even if you have to write it from scratch, I doubt it's
more work than what you've already put into trying to get the other
scheme to work.
BTW, there is a desire to be able to store some kind of visibility info
in a manner which could be used by indexes; that might allow your select
count(*)'s to perform adequately without maintaining a seperate summary
table.
On Thu, Jan 05, 2006 at 10:53:40AM +0200, Tsirkin Evgeny wrote:
>
> Bruno,thanks for the answer but this was not at ALL that i asked.
> Neither mind .
> Note however, how polite i am .
> Thanks anyway.
> Evgeny
>
> Bruno Wolff III wrote:
>
> >On Thu, Jan 05, 2006 at 10:34:31 +0200,
> > Tsirkin Evgeny <tsurkin@mail.jct.ac.il> wrote:
> >
> >
> >>I understand THAT ,I meant why int will give me more performance.
> >>
> >>
> >
> >Because if you have a bunch of processes sitting around waiting for table
> >locks, the average time to process queries will be higher. If you are
> >already limited by IO throughput or CPU usage this may not be a big deal,
> >but in many cases it will be.
> >
> >
> >
> >>Well i DO have a lot of concurrent queries,that is the whole point.
> >>
> >>
> >
> >Then you probably want to do what people have been recommending you do.
> >
> >
> >
> >>That does not help me .What i want is :
> >>select 1 from table a where whatever for update;
> >>issuing this should fire a trigger that does:
> >>
> >>
> >
> >You can't trigger on select statements. So this approach won't workin any
> >case.
> >
> >
> >
> >>select 1 from table counter where a.pkey=counter.ident or something
> >>however this should only be done for select FOR UPDATE!
> >>And i can't know that inside the trigger!
> >>
> >>
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 1: if posting/reading through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo@postgresql.org so that your
> > message can get through to the mailing list cleanly
> >
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>
--
Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: jnasby@pervasive.com, tsurkin@mail.jct.ac.il, bruno@wolff.to
Subject: Re: preventing deadlocks
In-Reply-To: <20060105210210.GX43311@pervasive.com>
References: <43B10E07.7010503@mail.jct.ac.il> <20051228202607.GA5194@wolff.to> <Pine.GSO.4.58_heb2.09.0601021131080.10840@ketubot.jct.ac.il> <20060104003001.GY82560@pervasive.com> <Pine.GSO.4.58_heb2.09.0601041035520.7100@ketubot.jct.ac.il> <20060105065747.GA17322@wolff.to> <43BCDA17.6070806@mail.jct.ac.il> <20060105084030.GA32572@wolff.to> <43BCDE94.3030902@mail.jct.ac.il> <20060105210210.GX43311@pervasive.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox