pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: kimaidou <kimaidou@gmail.com>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: Simple JOIN on heavy table not using expected index
Date: Fri, 09 Feb 2024 10:12:55 -0500
Message-ID: <1394633.1707491575@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMKXKO4tUH=nTZ-g09=wng+wSxtkj7K8yePMkfTiOpW4zT4Jdg@mail.gmail.com>
References: <CAMKXKO4tUH=nTZ-g09=wng+wSxtkj7K8yePMkfTiOpW4zT4Jdg@mail.gmail.com>

kimaidou <kimaidou@gmail.com> writes:
> It seems PostgreSQL does not use the index parcelles_dep_idx on "dep" (text
> field), even if the corresponding number of lines for this WHERE clause is
> a smal subset of the entire data:
> approx 6M against 80M in total

6M out of 80M rows is not a "small subset".  Typically I'd expect
the planner to use an index-based scan for up to 1 or 2 percent of
the table.  Beyond that, you're going to be touching most pages
of the table anyway.

You can try reducing random_page_cost to favor indexscans, but
you might not find that the query gets any faster.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <1394633.1707491575@sss.pgh.pa.us>
Permalink:  ../1394633.1707491575@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1394633.1707491575@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, kimaidou@gmail.com, pgsql-performance@lists.postgresql.org
  Subject: Re: Simple JOIN on heavy table not using expected index
  In-Reply-To: <1394633.1707491575@sss.pgh.pa.us>

* 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