Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 0AE8B6329D0 for ; Mon, 28 Jun 2010 10:42:11 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 92352-02 for ; Mon, 28 Jun 2010 13:41:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gx0-f174.google.com (mail-gx0-f174.google.com [209.85.161.174]) by mail.postgresql.org (Postfix) with ESMTP id 9F6D36323C8 for ; Mon, 28 Jun 2010 10:42:00 -0300 (ADT) Received: by gxk23 with SMTP id 23so65649gxk.19 for ; Mon, 28 Jun 2010 06:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=cb5JWqEcUKeY0mCu2F98RnZ9yzPqxVK8SMm/yfF68E4=; b=IhftTXOw/YC1AO2MEJ3OXvGzv1ZghmJAoqP3F7JhUjj87ysgiPmTrdzpY8TZYod8BQ etOD6RKfiHYXUcJUPIY6GuagowVxUzgOIlv9vNZlOVJho7X3ehv5fswVSnzp+fF/w78G BXML4weq7Y8913qNn/3W0HVIJOiMw0rxUO9GQ= 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=FCRr4VRZIm1VyoltxFPhiLKSRAt4POIVNzb/66IFFfCcK2dy0VlmMQ4BsyCoQxYGxU TDL6ugetyxemYRBGrAnCAewqHtFP7mvHzYiZerQKI2cUa1l3wN0uEFvckZ43TKRb5Mj+ adoIklQZYft/mQn4LMF13L5gdchTHD/BxxyoY= MIME-Version: 1.0 Received: by 10.229.221.84 with SMTP id ib20mr2670254qcb.93.1277732518763; Mon, 28 Jun 2010 06:41:58 -0700 (PDT) Received: by 10.229.233.80 with HTTP; Mon, 28 Jun 2010 06:41:58 -0700 (PDT) In-Reply-To: <4C2889EF.1050908@gmail.com> References: <4C2889EF.1050908@gmail.com> Date: Mon, 28 Jun 2010 19:11:58 +0530 Message-ID: Subject: Re: order by slowing down a query by 80 times From: Rajesh Kumar Mallah To: Yeb Havinga Cc: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=00163630f073e6208b048a1748b8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.801 tagged_above=-10 required=5 tests=BAYES_50=0.8, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201006/499 X-Sequence-Number: 39355 --00163630f073e6208b048a1748b8 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Jun 28, 2010 at 5:09 PM, Yeb Havinga wrote: > Rajesh Kumar Mallah wrote: > >> Dear List, >> >> just by removing the order by co_name reduces the query time dramatically >> from ~ 9 sec to 63 ms. Can anyone please help. >> > The 63 ms query result is probably useless since it returns a limit of 25 > rows from an unordered result. It is not surprising that this is fast. > > The pain is here: > > Index Scan using profile_master_co_name on profile_master b > (cost=0.00..1125295.59 rows=6968 width=25) (actual time=0.097..9193.154 > rows=2212 loops=1) > Filter: ((co_name IS NOT NULL) AND > ((co_name_vec)::tsvector @@ to_tsquery('manufacturer'::text))) > > > It looks like seq_scans are disabled, since the index scan has only a > filter expression but not an index cond. > seq_scans is NOT explicitly disabled. The two queries just differed in the order by clause. regds Rajesh Kumar Mallah. > > regards, > Yeb Havinga > > > >> Regds >> Rajesh Kumar Mallah. >> > --00163630f073e6208b048a1748b8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Mon, Jun 28, 2010 at 5:09 PM, Yeb Hav= inga <yebhavin= ga@gmail.com> wrote:
Rajesh Kumar Mallah wrote:
Dear List,

just by removing the order by co_name reduces the query time dramatically from =A0~ 9 sec =A0to 63 ms. Can anyone please help.
The 63 ms query result is probably useless since it returns a limit of 25 r= ows from an unordered result. It is not surprising that this is fast.

The pain is here:

Index Scan using profile_master_co_name on profile_master b =A0(cost=3D0.00= ..1125295.59 rows=3D6968 width=3D25) (actual time=3D0.097..9193.154 rows=3D= 2212 loops=3D1)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Filter: ((c= o_name IS NOT NULL) AND ((co_name_vec)::tsvector @@ to_tsquery('manufac= turer'::text)))


It looks like seq_scans are disabled, since the index scan has only a filte= r expression but not an index cond.


seq_scans = is NOT explicitly disabled. The two queries just differed in the order by c= lause.

regds
Rajesh Kumar Mallah.
=A0

regards,
Yeb Havinga



Regds
Rajesh Kumar Mallah.

--00163630f073e6208b048a1748b8--