X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4AA7E5E46CD for ; Mon, 30 Aug 2004 15:07:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85985-09 for ; Mon, 30 Aug 2004 18:07:19 +0000 (GMT) Received: from emepe3.com (unknown [69.93.218.52]) by svr1.postgresql.org (Postfix) with ESMTP id 7EBA75E46CC for ; Mon, 30 Aug 2004 15:07:19 -0300 (ADT) Received: from [200.89.130.112] (helo=[192.168.0.101]) by emepe3.com with asmtp (Exim 3.35 #1 (Debian)) id 1C1qpP-00085w-00; Mon, 30 Aug 2004 13:24:28 -0500 Subject: Re: seqscan instead of index scan From: Martin Sarsale To: Bruno Wolff III Cc: pgsql-performance@postgresql.org In-Reply-To: <20040830180227.GA32520@wolff.to> References: <1093887997.1680.71.camel@kadaif> <20040830180227.GA32520@wolff.to> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-BzpkraxbnHvJL81BJ7a8" Organization: Emepe3.com Inc Message-Id: <1093889235.1680.77.camel@kadaif> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 30 Aug 2004 15:07:15 -0300 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/448 X-Sequence-Number: 8084 --=-BzpkraxbnHvJL81BJ7a8 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Mon, 2004-08-30 at 15:02, Bruno Wolff III wrote: > On Mon, Aug 30, 2004 at 14:46:37 -0300, > > Im having a weird problem here. I have a table w/ ~180.000 rows and I > > want to select those where c > 0 or d > 0 (there only a few of those on > > the table) > > I indexed columns c and d (separately) but this query used the slow > > seqscan instead of the index scan: >=20 > Postgres doesn't 'or' bitmaps derived from two indexes. You might have mo= re > luck using a combined index. With combined index, you mean a multiple column index? From http://www.postgresql.org/docs/7.4/interactive/indexes-multicolumn.html =20 "Multicolumn indexes can only be used if the clauses involving the indexed columns are joined with AND. For instance, SELECT name FROM test2 WHERE major =3D constant OR minor =3D constant; cannot make use of the index test2_mm_idx defined above to look up both columns. (It can be used to look up only the major column, however.) " But I need something like: select * from t where c<>0 or d<>0; --=-BzpkraxbnHvJL81BJ7a8 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBBM2zThruVGj+ub3MRAmboAKCkBK6xUlLrkHcolaRA89Bg9X0C7gCeJEci KPgkINw1mfoHesdQWu4OjFM= =iVgM -----END PGP SIGNATURE----- --=-BzpkraxbnHvJL81BJ7a8--