pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Sergei Kornilov <sk@zsrv.org>
Cc: mayank rupareliya <mayankjr03@gmail.com>
Cc: pgsql-performance@lists.postgresql.org <pgsql-performance@lists.postgresql.org>
Subject: Re: Searching in varchar column having 100M records
Date: Wed, 17 Jul 2019 14:48:46 +0200
Message-ID: <20190717124846.xbvcvfjg5hdcnaed@development> (raw)
In-Reply-To: <27574631563364400@iva5-fb4da115b4b5.qloud-c.yandex.net>
References: <CACX+qbyQJsdzwVx0bVWp-rYXu-TdPVHCAJ+vb02ZnJtCXOofCw@mail.gmail.com>
	<27574631563364400@iva5-fb4da115b4b5.qloud-c.yandex.net>

On Wed, Jul 17, 2019 at 02:53:20PM +0300, Sergei Kornilov wrote:
>Hello
>
>Please recheck with track_io_timing = on in configuration. explain
>(analyze,buffers) with this option will report how many time we spend
>during i/o
>
>>   Buffers: shared hit=2 read=31492
>
>31492 blocks / 65 sec ~ 480 IOPS, not bad if you are using HDD
>
>Your query reads table data from disks (well, or from OS cache). You need
>more RAM for shared_buffers or disks with better performance.
>

Either that, or try creating a covering index, so that the query can do an
index-only scan. That might reduce the amount of IO against the table, and
in the index the data should be located close to each other (same page or
pages close to each other).

So try something like

    CREATE INDEX ios_idx ON table (field, user_id);

and make sure the table is vacuumed often enough (so that the visibility
map is up to date).


regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services






view thread (13+ messages)  latest in thread

Message-ID: <20190717124846.xbvcvfjg5hdcnaed@development>
Permalink:  ../20190717124846.xbvcvfjg5hdcnaed@development/
Also on:    postgresql.org/message-id/20190717124846.xbvcvfjg5hdcnaed@development

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tomas.vondra@2ndquadrant.com, sk@zsrv.org, mayankjr03@gmail.com, pgsql-performance@lists.postgresql.org
  Subject: Re: Searching in varchar column having 100M records
  In-Reply-To: <20190717124846.xbvcvfjg5hdcnaed@development>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox