Re: [PERFORM] Speedier count(*)

2005-08-11 Thread Dan Harris
Thanks for all the great ideas. I have more options to evaluate now. -Dan ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [PERFORM] Speedier count(*)

2005-08-11 Thread Tino Wildenhain
Am Donnerstag, den 11.08.2005, 14:08 +0200 schrieb PFC: > > > You could lock the count table to prevent the problem > > where 2 competing transactions do an insert, read the > > start value and add 1 to it and then write the result > > - which is n+1 rather then n+2 - so you are off by one. > > Th

Re: [PERFORM] Speedier count(*)

2005-08-11 Thread PFC
You could lock the count table to prevent the problem where 2 competing transactions do an insert, read the start value and add 1 to it and then write the result - which is n+1 rather then n+2 - so you are off by one. Think of the same when one transaction inserts 100 and the other 120. Then yo

Re: [PERFORM] Speedier count(*)

2005-08-11 Thread Tino Wildenhain
Am Donnerstag, den 11.08.2005, 20:36 +1000 schrieb Gavin Sherry: > On Thu, 11 Aug 2005, Tino Wildenhain wrote: > > > Am Donnerstag, den 11.08.2005, 00:40 -0400 schrieb Mark Cotner: > > > Here's a trigger I wrote to perform essentially the same purpose. The > > > nice > > > thing about this is it

Re: [PERFORM] Speedier count(*)

2005-08-11 Thread Gavin Sherry
On Thu, 11 Aug 2005, Tino Wildenhain wrote: > Am Donnerstag, den 11.08.2005, 00:40 -0400 schrieb Mark Cotner: > > Here's a trigger I wrote to perform essentially the same purpose. The nice > > thing about this is it keeps the number up to date for you, but you do incur > > slight overhead. > ...

Re: [PERFORM] Speedier count(*)

2005-08-11 Thread Tino Wildenhain
Am Donnerstag, den 11.08.2005, 00:40 -0400 schrieb Mark Cotner: > Here's a trigger I wrote to perform essentially the same purpose. The nice > thing about this is it keeps the number up to date for you, but you do incur > slight overhead. ... > > CREATE TRIGGER del_rowcount_tr BEFORE DELETE ON te

Re: [PERFORM] Speedier count(*)

2005-08-10 Thread Mark Cotner
Here's a trigger I wrote to perform essentially the same purpose. The nice thing about this is it keeps the number up to date for you, but you do incur slight overhead. CREATE TABLE test (id serial primary key, name varchar(20)); CREATE TABLE rowcount (tablename varchar(50), rowcount bigint defa

Re: [PERFORM] Speedier count(*)

2005-08-10 Thread Gavin Sherry
Hi Dan, On Wed, 10 Aug 2005, Dan Harris wrote: > I have a web page for my customers that shows them count of records > and some min/max date ranges in each table of a database, as this is > how we bill them for service. They can log in and check the counts > at any time. I'd like for the counts

Re: [PERFORM] Speedier count(*)

2005-08-10 Thread John A Meinel
Dan Harris wrote: > I have a web page for my customers that shows them count of records and > some min/max date ranges in each table of a database, as this is how we > bill them for service. They can log in and check the counts at any > time. I'd like for the counts to be as fresh as possible

Re: [PERFORM] Speedier count(*)

2005-08-10 Thread Michael Fuhr
On Wed, Aug 10, 2005 at 05:37:49PM -0600, Dan Harris wrote: > Also, I am using "select ... group by ... order by .. limit 1" to get > the min/max since I have already been bit by the issue of min() max() > being slower. PostgreSQL 8.1 will have optimizations for certain MIN and MAX queries. h

Re: [PERFORM] Speedier count(*)

2005-08-10 Thread Joshua D. Drake
Also, I am using "select ... group by ... order by .. limit 1" to get the min/max since I have already been bit by the issue of min() max() being slower. This specific instance is fixed in 8.1 Sincerely, Joshua D. Drake -Dan ---(end of broadcast)---