This is a discussion on count(*) index within the pgsql Novice forums, part of the PostgreSQL category; --> Hi! Yes, i know, mvcc, and can't use indexes. And i know the workaround for max() and min(). Is ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi! Yes, i know, mvcc, and can't use indexes. And i know the workaround for max() and min(). Is there some workaround for count()? select count(*) from table where field=1; and field has a nice index. And this is slooooow. -- Tomka Gergely Tudom, anyu. Sapka, sál, doksi. ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster |
| ||||
| On Fri, Jan 07, 2005 at 19:22:56 +0100, Tomka Gergely <tomka@zeus.gau.hu> wrote: > Hi! > > Yes, i know, mvcc, and can't use indexes. And i know the workaround for > max() and min(). Is there some workaround for count()? > > select count(*) from table where field=1; > > and field has a nice index. And this is slooooow. If there are few records where field=1 then an index will be used. You may get better performance maintaining a count table using triggers. This may not work well of there are lots of concurrent updates. ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) |