Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-03-01 Thread Alan Acosta
] On Behalf Of Andrew Sullivan Sent: Monday, February 28, 2011 4:28 PM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question ! On Mon, Feb 28, 2011 at 04:12:30PM -0500, Alan Acosta wrote: My application is trying to generate a numbered place

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-03-01 Thread Andrew Sullivan
On Tue, Mar 01, 2011 at 09:23:49AM -0500, Alan Acosta wrote: seats have an specific bus even 5 minutes before departure, sometimes i know sometimes i don't, even sometimes when i know i have to change on fly this capacity, for example my bus crash just before departure, so i have to use a

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-03-01 Thread Alan Acosta
Yep i already have those columns and unique constraint, my issue isn't sell the seat two times, i was a lot of paranoiac about that and use a lock mode to restricted for that. I will check if i can create rows for seats before sell and use update, so i can use SELECT FOR UPDATE and not use insert,

[GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Alan Acosta
Hi everyone ! I'm using lock with ACCESS EXCLUSIVE in several of my tables to assure that only one process write in those tables at same time, this is blocking my SELECT, and this is what i want, but, deadlocks start to showing more and more in my logs when SELECTS failt to get his Share Lock

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Andrew Sullivan
On Mon, Feb 28, 2011 at 12:43:58PM -0500, Alan Acosta wrote: I'm using lock with ACCESS EXCLUSIVE in several of my tables to assure that only one process write in those tables at same time Why are you doing that? It sounds like a bad idea to me. But anyway, I believe that the SHARE lock

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Alan Acosta
Andrew, thank you very much for reply ! I already update my bookmark for 8.3 which is my current version, http://www.postgresql.org/docs/8.3/static/explicit-locking.html, i see new things here, like a comparative table. Yep, seems like ACCESS EXCLUSIVE is a bad idea, at least now :p ! i check

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Andrew Sullivan
On Mon, Feb 28, 2011 at 03:32:08PM -0500, Alan Acosta wrote: your recommendation about to use SHARE mode, but in http://www.postgresql.org/docs/8.3/static/explicit-locking.html i see that SHARE mode doesn't lock against itself, so, another thread using the same mode will be able to access the

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Alan Acosta
My threads use each one different conecctions, so the transactions are different, may be my bad English doesn't help to much, sorry for that ! My application is trying to generate a numbered place for a client inside a bus, and to avoid to sell the place number 5 to two people, so i need to avoid

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Andrew Sullivan
On Mon, Feb 28, 2011 at 04:12:30PM -0500, Alan Acosta wrote: My application is trying to generate a numbered place for a client inside a bus, and to avoid to sell the place number 5 to two people, so i need to avoid that two sellers to sell the same place to same time, when i start my

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Alan Acosta
I really appreciate your help Andrew, and yep, i already starto to feel some pain lol. I suppose is true but is better to ask, SELECT FOR UPDATE is faster than LOCK ? Thanks for the recommendations, i will check them ^_^ Cheers, Alan Acosta On Mon, Feb 28, 2011 at 4:28 PM, Andrew Sullivan

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Andrew Sullivan
On Mon, Feb 28, 2011 at 05:13:11PM -0500, Alan Acosta wrote: I really appreciate your help Andrew, and yep, i already starto to feel some pain lol. I suppose is true but is better to ask, SELECT FOR UPDATE is faster than LOCK ? SELECT FOR UPDATE locks the row you're trying to lock. So it's

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Alan Acosta
But i have a new problem there, i have no rows for update, i create new rows when the seats are sold, cause rarely the database knows the capacity of the bus, number of seats, even some bus doesn't have seat number 4 for example :p. So i cannot SELECT FOR UPDATE no existent rows, but i still need

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Bosco Rama
Alan Acosta wrote: But i have a new problem there, i have no rows for update, i create new rows when the seats are sold, cause rarely the database knows the capacity of the bus, number of seats, even some bus doesn't have seat number 4 for example :p. So i cannot SELECT FOR UPDATE no existent

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Adrian Klaver
On Monday, February 28, 2011 2:39:07 pm Alan Acosta wrote: But i have a new problem there, i have no rows for update, i create new rows when the seats are sold, cause rarely the database knows the capacity of the bus, number of seats, even some bus doesn't have seat number 4 for example So

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread Andrew Sullivan
On Mon, Feb 28, 2011 at 05:39:07PM -0500, Alan Acosta wrote: But i have a new problem there, i have no rows for update, i create new rows when the seats are sold, cause rarely the database knows the capacity of the bus, number of seats, even some bus doesn't have seat number 4 for example :p.

Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question !

2011-02-28 Thread David Johnston
Sullivan Sent: Monday, February 28, 2011 4:28 PM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Lock ACCESS EXCLUSIVE and Select question ! On Mon, Feb 28, 2011 at 04:12:30PM -0500, Alan Acosta wrote: My application is trying to generate a numbered place for a client inside a bus