Re: [GENERAL] Select max(id) causes AccessExclusiveLock?

2014-04-28 Thread Stephen Frost
Edson, * Edson Richter (edsonrich...@hotmail.com) wrote: > The programmer added a > > LOCK TABLE MyTableName > > just before issuing the select max(id) from MyTableName. > > I do suspect this is the case, right? Yup, that'll do it. http://www.postgresql.org/docs/9.3/static/sql-lock.html

Re: [GENERAL] Select max(id) causes AccessExclusiveLock?

2014-04-28 Thread Edson Richter
Em 28/04/2014 12:01, Tom Lane escreveu: Edson Richter writes: When I issue a select max(id) from MyTableName Postgres 9.2.7 is scaling a AccessExclusiveLock and causing large delays. Really? regression=# create table MyTableName ( regression(#id integer not null primary key, regression(#

Re: [GENERAL] Select max(id) causes AccessExclusiveLock?

2014-04-28 Thread Tom Lane
Edson Richter writes: > When I issue a > select max(id) from MyTableName > Postgres 9.2.7 is scaling a AccessExclusiveLock and causing large delays. Really? regression=# create table MyTableName ( regression(#id integer not null primary key, regression(#seqYear char(4), regression(#s

[GENERAL] Select max(id) causes AccessExclusiveLock?

2014-04-28 Thread Edson Richter
On table create table MyTableName ( id integer not null primary key, seqYear char(4), seqCount integer, ...) Where id is primary key and (seqYear, seqCount) is a unique index. Table facts: about 40 fields, 1 million records. When I issue a select max(id) from MyTableName Postgres 9.2

Re: [GENERAL] select max()

2010-11-30 Thread Alexander Farber
Ok, it is # select id from pref_money where money in (select max(money) from pref_money group by yw); id DE8048 VK91770810 DE7115 OK252342810632 OK22853997 (5 rows) And to see how many times a player has won is: # select count(id) from pref_money where id='DE7115

[GENERAL] select max()

2010-11-30 Thread Alexander Farber
Hello, I have this table where I store player results for each week: # select * from pref_money limit 5; id | money | yw +---+- OK32378280203 | -27 | 2010-44 OK274037315447 | -56 | 2010-44 OK19644992852 | 8 | 2010-44 OK21807961329 | 114

Re: [GENERAL] Select max(primary_key) taking a long time

2010-05-22 Thread Francisco Reyes
Merlin Moncure writes: do a big delete recently? any other open transactions? Some inserts were taking place. Roughly 2 to 5 million rows inside transactions. We were doing some ETL and each batch represented a file we were loading. We need to have the entire file or roll back so each file

Re: [GENERAL] Select max(primary_key) taking a long time

2010-05-22 Thread Merlin Moncure
On Fri, May 21, 2010 at 1:48 PM, Francisco Reyes wrote: > Tom Lane writes: > >> Francisco Reyes writes: >>> >>> I am trying to do >>> select max(primary_key) from some_table; >> >> Are there a whole lot of nulls in that column? > > > Zero nulls. It is a primary key. do a big delete recently? an

Re: [GENERAL] Select max(primary_key) taking a long time

2010-05-21 Thread Tom Lane
Francisco Reyes writes: > Tom Lane writes: >> Francisco Reyes writes: >>> I am trying to do >>> select max(primary_key) from some_table; >> Are there a whole lot of nulls in that column? > Zero nulls. It is a primary key. Huh. The proposed plan should have run in basically zero time then. You

Re: [GENERAL] Select max(primary_key) taking a long time

2010-05-21 Thread Francisco Reyes
Tom Lane writes: Francisco Reyes writes: I am trying to do select max(primary_key) from some_table; Are there a whole lot of nulls in that column? Zero nulls. It is a primary key. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:

Re: [GENERAL] Select max(primary_key) taking a long time

2010-05-21 Thread Tom Lane
Francisco Reyes writes: > I am trying to do > select max(primary_key) from some_table; Are there a whole lot of nulls in that column? regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www

[GENERAL] Select max(primary_key) taking a long time

2010-05-21 Thread Francisco Reyes
Postgres 8.4.1 CentOS 5.4 I am trying to do select max(primary_key) from some_table; The explain looks like: explain select max(primary_key) from some_table; QUERY PLAN -

Re: [GENERAL] select max from subquery

2009-02-15 Thread searchelite
Oleg Bartunov wrote: > > yOn Sat, 14 Feb 2009, searchelite wrote: > >> >> Dear All >> >> i gave this kind of query >> >> select max(foo) from (select some statement) as foo >> >> but it gave me this error >> ERROR: function max(record) does not exist >> >> >> any help how i can select max val

Re: [GENERAL] select max from subquery

2009-02-14 Thread Oleg Bartunov
yOn Sat, 14 Feb 2009, searchelite wrote: Dear All i gave this kind of query select max(foo) from (select some statement) as foo but it gave me this error ERROR: function max(record) does not exist any help how i can select max value from suqbuery in main query like this: select max(fo

Re: [GENERAL] select max from subquery

2009-02-14 Thread Grzegorz Jaƛkiewicz
select max(foo.record) from ... ? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] select max from subquery

2009-02-14 Thread Raymond O'Donnell
On 14/02/2009 11:05, searchelite wrote: > select max(foo) from (select some statement) as foo Can you post the full query? It's very hard to tell from this. Also, I think you may need to give the subquery an alias, thus: select max(foo) from ( ) s as foo Ray. --

[GENERAL] select max from subquery

2009-02-14 Thread searchelite
Dear All i gave this kind of query select max(foo) from (select some statement) as foo but it gave me this error ERROR: function max(record) does not exist any help how i can select max value from suqbuery in main query thanks -- View this message in context: http://www.nabble.com/select-