Re: [SQL] Some insight on the proper SQL would be appreciated

2010-06-08 Thread Mikhail V. Puzanov
Hi, Something very straightforward looks like this, I guess: select * from users u where ( select count(*) from users u1 where u1.username = u.username and u1.signedup> u.signedup )< 5 to get recent results. Or "u1.signedup< u.signedup" for the first ones. But that doesn't work i

[SQL] atomic multi-threaded upsert

2010-11-24 Thread Mikhail V. Puzanov
Hi, All I'm trying to make a kind of upsert for the following table: CREATE TABLE sequences ( section VARCHAR( 50 ) NOT NULL, name VARCHAR( 50 ) NOT NULL, counter BIGINT NOT NULL ); CREATE UNIQUE INDEX IDX_SEQUENCES_SN ON sequences(section, name); Next, I execute the following two

Re: [SQL] atomic multi-threaded upsert

2010-11-27 Thread Mikhail V. Puzanov
On 25.11.2010 12:51, MIkhail Puzanov wrote: > > > 2010/11/25 Tom Lane mailto:t...@sss.pgh.pa.us>> > > "Mikhail V. Puzanov" <mailto:misha.puza...@gmail.com>> writes: > >-- increment and get the counter if exists > > UPDATE