X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C357E475F1B for ; Fri, 11 Apr 2003 18:02:36 -0400 (EDT) Received: from nycsmtp5out-eri0.rdc-nyc.rr.com (nycsmtp5out-eri0.rdc-nyc.rr.com [24.29.99.228]) by postgresql.org (Postfix) with ESMTP id 26C99475EDF for ; Fri, 11 Apr 2003 18:02:36 -0400 (EDT) Received: from math-hat.com (66-65-68-41.nyc.rr.com [66.65.68.41]) by nycsmtp5out-eri0.rdc-nyc.rr.com (8.12.1/Road Runner SMTP Server 1.0) with SMTP id h3BLqmwL019129; Fri, 11 Apr 2003 17:52:48 -0400 (EDT) Received: (nullmailer pid 23268 invoked by uid 1000); Fri, 11 Apr 2003 22:02:37 -0000 To: josh@agliodbs.com Cc: pgsql-sql@postgresql.org Subject: Re: count(*), EXISTS, indexes Mail-Copies-To: never From: Itai Zukerman Date: Fri, 11 Apr 2003 18:02:37 -0400 In-Reply-To: <200304111442.48107.josh@agliodbs.com> (Josh Berkus's message of "Fri, 11 Apr 2003 14:42:48 -0700") Message-ID: <87he94r8ua.fsf@matt.w80.math-hat.com> User-Agent: Gnus/5.090018 (Oort Gnus v0.18) Emacs/21.2 (gnu/linux) References: <874r54sr8q.fsf@matt.w80.math-hat.com> <200304111353.50162.josh@agliodbs.com> <871y08sq0e.fsf@matt.w80.math-hat.com> <200304111442.48107.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-22.6 required=5.0 tests=BAYES_01,IN_REP_TO,REFERENCES,USER_AGENT_GNUS_UA 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/188 X-Sequence-Number: 12889 >> # explain select sum(weight) from rprofile rp where exists (select 1 from > rcount_prof rcp where rcp.profile ~<= rp.profile and ~rcp.psig ~<= rp.psig > and rcp.filter='{734,1944}'); > > I'm not familiar with the "~" that you have in the query. What are those for? They are my own operators and functions. profile is a integer array and the ~'s are subset operators. psig is a bit signature, "~" is complement, and the ~ operators again are subset operators. > Do you have an index on rcp.profile, rcp.psig, rcp.filter? Yes, yes, and yes. ATM, though, there are only about 50 rows in rcount_prof. The vast majority of time is spent scanning the 600,000-row rprofile table. -- Itai Zukerman