Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 2B30D632DF4 for ; Mon, 1 Feb 2010 01:16:28 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 75749-02 for ; Mon, 1 Feb 2010 05:16:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f224.google.com (mail-ew0-f224.google.com [209.85.219.224]) by mail.postgresql.org (Postfix) with ESMTP id E4F956360B1 for ; Mon, 1 Feb 2010 01:16:16 -0400 (AST) Received: by ewy24 with SMTP id 24so752008ewy.16 for ; Sun, 31 Jan 2010 21:16:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=TR+3++yA9zx513l+YDYwtuE8Ptr3MEyfN5GtRq6U8xs=; b=Gx0wYCM76vs2pddPWGlEXORW4XkQMSWoJ4skopftVyLiOTi2l1fXPyFN1vWfBcmE6x h8uZAlVqL7Sfforqn1qQ7L/6W4k1rU501aETtGDXEz+c7YqCxCfxJawOxUdMc2kip7sT kZIHdqORNEPRrYSe4CgOyEga6eSAj0QWuR7XM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=N4M6/BlbXOB2JQbwhY/ZGR/kqViue7lVjdGBI2gNQa0pjYlZA40LIkqqxYELhRPtzw QuNxsB522ob+RPir63M+UEnlElRUYFMSHaoAPUwwOJ6YuiCCFgODpGJ+xdDzkwGu/1Dk YR6mYhylfsbqbflfPrLKIa3R+bVBx21Idp3BE= MIME-Version: 1.0 Received: by 10.216.85.143 with SMTP id u15mr2019500wee.205.1265001375729; Sun, 31 Jan 2010 21:16:15 -0800 (PST) In-Reply-To: <1f30b80c1001312025m118d5798lcb599aeb517beddc@mail.gmail.com> References: <1f30b80c1001290049ub864091r8298fca3daa0eb69@mail.gmail.com> <1f30b80c1001311650q264dfda0uf9894cac3b9e0c3e@mail.gmail.com> <28233.1264995140@sss.pgh.pa.us> <1f30b80c1001312025m118d5798lcb599aeb517beddc@mail.gmail.com> Date: Sun, 31 Jan 2010 22:16:15 -0700 Message-ID: Subject: Re: Fwd: Help required on query performance From: Scott Marlowe To: dclements89@gmail.com Cc: Tom Lane , pgsql-sql Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/4 X-Sequence-Number: 33603 On Sun, Jan 31, 2010 at 9:25 PM, Dave Clements wrote: > After the analyze I am getting the time 3.20 ms but there is not > HashJoin there. Still all of them are NestLoops. But that is fine. > > Now the only problem is the sequence scan on sq_sch_idx table. > I have a query like this: > > explain analyze select count(*) from sq_sch_idx where value = '%download%'; > > This query does a sequence scan on the table. Is there a way I can > create an index for this? If it's not left anchored ( value like 'download%') then not with regular old methods. If you need to do text searching you might need to look into the full text search indexing in pgsql.