Folks, Please find enclosed a patch that shows how to get a quick approximation of count(*) on a table.
Cheers, D -- David Fetter [EMAIL PROTECTED] http://fetter.org/ phone: +1 510 893 6100 mobile: +1 415 235 3778 Remember to vote!
Index: doc/src/sgml/func.sgml =================================================================== RCS file: /projects/cvsroot/pgsql/doc/src/sgml/func.sgml,v retrieving revision 1.241 diff -c -r1.241 func.sgml *** doc/src/sgml/func.sgml 14 Mar 2005 18:31:19 -0000 1.241 --- doc/src/sgml/func.sgml 24 Mar 2005 16:25:55 -0000 *************** *** 7330,7339 **** </para> <para> ! Unfortunately, there is no similarly trivial query that can be ! used to improve the performance of <function>count()</function> ! when applied to the entire table. </para> </note> </sect1> --- 7330,7348 ---- </para> <para> ! When the table has been <command>VACUUM</command>ed recently, but ! only then, a good approximation of count(*) for an entire table ! can be obtained as follows: ! <programlisting> ! SELECT reltuples FROM pg_class WHERE relname = 'sometable'; ! </programlisting> ! </para> ! ! <para> ! Unfortunately, there is not yet a general trivial query that can ! be used to improve the performance of <function>count()</function>. </para> + </note> </sect1>
---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match