Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hoXnO-0000ee-Lk for pgsql-performance@arkaria.postgresql.org; Fri, 19 Jul 2019 18:39:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hoXnN-0004MB-ED for pgsql-performance@arkaria.postgresql.org; Fri, 19 Jul 2019 18:39:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hoXnM-0004M4-Vv for pgsql-performance@lists.postgresql.org; Fri, 19 Jul 2019 18:39:53 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hoXnJ-0005b3-SN for pgsql-performance@lists.postgresql.org; Fri, 19 Jul 2019 18:39:52 +0000 Received: by mail-wr1-x441.google.com with SMTP id p17so33141695wrf.11 for ; Fri, 19 Jul 2019 11:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=gLuivkHXmm/qPjuoO+ua7GOtKZuKkuv6CnezmAR7ags=; b=yYlUToBkfv7/76WXxAKoYCCdeQBooedBCgcnUPJXPv3YSLODt7Nj/7FrdoD0Guet/N kL9N+Uh1E8I6vCZ4hN8lKb8ct+bO+fqyMrzlX21xLbnSxiBoh90AT7lvJ78jjXxBHsrN Wi6nzeJOBXHOOCJdEP3sKR2+q6CliyLMdprMNlSGmyrj1s0yeBSKVHYOzkOMhKpS9UXB +nmFk06x+Z/jFmAnmVrKnJ7iXEC5h0niSFDgEa0OoPJgEE/1q1lHYkrtLXBeH56XAFND yEpc0CU0xmwQ5wLSt0ZDTq9BK4WxYDYia3jz/5OqhpJBuLHAibYDSI4Ngby45qTBHowT Os9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=gLuivkHXmm/qPjuoO+ua7GOtKZuKkuv6CnezmAR7ags=; b=F0nJHU1Cmf2E3VjLup6q/NP/ff/0bl9PSMasKSJyz1gosAVoHE/Wnl6S9BYZSNjfH+ 55e59MubN6h18/2Jn4z1YHVcTDiYFbeK3loWSMJiWmb6z1/aBQsdm18NJU20z5aqGeAH Gjku/4+E/kTAmUDlMkOScA5vdOnfl4MGRYC50hB1UNGI72bIvWMzU40YTXqvknA16qoc Ij/lGEgU/r4qeTTg7078H7Yphxa3brbJfBZk858LOzT/3hCbbEQv4ArsX57cRkhJXXQ/ EcFz2HYQXlOFYO45lgKkvZSF5LjRe4MNKR9FXVnrvhsKvIJg/39lWjJ76T6kkIS/VO3m rckw== X-Gm-Message-State: APjAAAVVfwKGkJJCbmF1F/AYzlTu8OjOmQHHGwuycwA2iutT7vIil9D8 Q2SwM2Cbp4zOmK2VrDaV9nrAlw== X-Google-Smtp-Source: APXvYqyDYoGw6SsSTe/IFPO8G4sSI1PSeUjgo7T9LJCKSSqwHm7Z3BHgRJlKXrBvs13Xv2sciXVwUQ== X-Received: by 2002:adf:ed4a:: with SMTP id u10mr61301383wro.284.1563561589095; Fri, 19 Jul 2019 11:39:49 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id s2sm25859987wmj.33.2019.07.19.11.39.48 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 19 Jul 2019 11:39:48 -0700 (PDT) Date: Fri, 19 Jul 2019 20:39:46 +0200 From: Tomas Vondra To: mayank rupareliya Cc: pgsql-performance@lists.postgresql.org Subject: Re: Searching in varchar column having 100M records Message-ID: <20190719183946.ls5vmus7ukhbl63w@development> References: <20190718124109.2k22rkcrhviee5po@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Jul 19, 2019 at 07:43:26PM +0530, mayank rupareliya wrote: >Well, you haven't shown us the execution plan, so it's hard to check why >it did not help much and give you further advice. > > >This is the latest query execution with explain after adding indexing on >both columns. > >Aggregate (cost=174173.57..174173.58 rows=1 width=8) (actual >time=65087.657..65087.658 rows=1 loops=1) > -> Bitmap Heap Scan on fields (cost=1382.56..174042.61 rows=52386 >width=0) (actual time=160.340..65024.533 rows=31857 loops=1) > Recheck Cond: ((field)::text = 'Champlin'::text) > Heap Blocks: exact=31433 > -> Bitmap Index Scan on index_field (cost=0.00..1369.46 >rows=52386 width=0) (actual time=125.078..125.079 rows=31857 loops=1) > Index Cond: ((field)::text = 'Champlin'::text) >Planning Time: 8.595 ms >Execution Time: 65093.508 ms > That very clearly does not use the index-only scan, so it's not surprising it's not any faster. You need to find out why the planner makes that decision. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services