X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3C2CE475E14; Tue, 8 Apr 2003 19:46:34 -0400 (EDT) Received: from svana.org (svana.org [203.20.62.76]) by postgresql.org (Postfix) with ESMTP id 52926474E42; Tue, 8 Apr 2003 19:46:33 -0400 (EDT) Received: from kleptog by svana.org with local (Exim 3.35 #1 (Debian)) id 1932nH-0006P3-00; Wed, 09 Apr 2003 09:46:23 +1000 Date: Wed, 9 Apr 2003 09:46:23 +1000 From: Martijn van Oosterhout To: Denis Cc: pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: Yet Another (Simple) Case of Index not used Message-ID: <20030408234623.GD15928@svana.org> Reply-To: Martijn van Oosterhout Mail-Followup-To: Denis , pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IMjqdzrDRly81ofr" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.28i X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 X-PGP-Key-URL: X-Spam-Status: No, hits=-45.1 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/544 X-Sequence-Number: 40609 --IMjqdzrDRly81ofr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 08, 2003 at 12:57:16PM -0700, Denis wrote: > The query I am trying to do (fast) is: >=20 > select count(*) from addresses; >=20 > This takes more than a second to complete, because, as the 'explain' comm= and > shows me, > the index created on 'addresses' is not used, and a seq scan is being use= d. > One would assume that the creation of an index would allow the counting of > the number of entries in a table to be instantanous? Incorrect assumption. select count(*) can produce different results in different backends depending on the current state of the active transactions. --=20 Martijn van Oosterhout http://svana.org/kleptog/ > "the West won the world not by the superiority of its ideas or values or > religion but rather by its superiority in applying organized violence. > Westerners often forget this fact, non-Westerners never do." > - Samuel P. Huntington --IMjqdzrDRly81ofr Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE+k19PY5Twig3Ge+YRAs7pAJ4kxoQQnRu1zQeCzfB+8lRA4XgTtQCeMb1T m2DuiE8HICjO5qVCcVKdgUI= =LkBi -----END PGP SIGNATURE----- --IMjqdzrDRly81ofr--