From: | Marti Raudsepp <marti(at)juffo(dot)org> |
---|---|
To: | Emanuel Alvarez <ema(at)abductedcow(dot)com(dot)ar> |
Cc: | PG-General Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: seq vs index scan in join query |
Date: | 2017-11-29 14:57:32 |
Message-ID: | CABRT9RCb=SeHeZaMTyEO5U=oOxgoXOrSMc81MbakvKhX+gzS8w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi
On Wed, Nov 29, 2017 at 8:55 AM, Emanuel Alvarez <ema(at)abductedcow(dot)com(dot)ar> wrote:
> on the other hand, if we disable sequential scans (SET enable_seqscan
> = 0), we see than not only the query runs faster but the cost seems to
> be lower, as seen in the query plan [2].
True, the cost of the scan itself is lower, but together with
hashjoin/nestloop, the total cost of plan [2] is higher.
This is a wild guess but...
-> Index Scan using keywords_pkey on keywords
Buffers: shared hit=284808 read=4093
vs
-> Seq Scan on keywords
Buffers: shared read=36075
Looks like the index scan's advantage in this example is a much higher
cache hit ratio (despite touching so many more pages) and PostgreSQL
is underestimating it.
Have you tuned the effective_cache_size setting? A good starting point
is half the total RAM in your machine. It would be interesting to see
how high you need to set it for the planner to switch to the index
scan plan.
Regards,
Marti Raudsepp
From | Date | Subject | |
---|---|---|---|
Next Message | Nicola Contu | 2017-11-29 15:39:41 | pg_replication_slots |
Previous Message | Tom Lane | 2017-11-29 14:55:06 | Re: large numbers of inserts out of memory strategy |