Re: COUNT(*) and index-only scans

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Aidan Van Dyk" <aidan(at)highrise(dot)ca>,"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Jeff Davis" <pgsql(at)j-davis(dot)com>, "Greg Stark" <stark(at)mit(dot)edu>, "Bruce Momjian" <bruce(at)momjian(dot)us>, "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COUNT(*) and index-only scans
Date: 2011-10-12 15:26:06
Message-ID: 4E956B3E0200002500041EAA@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Aidan Van Dyk <aidan(at)highrise(dot)ca> wrote:

> The elephant in the room is that the index-only-scan really
> doesn't save a *whole* lot if the heap pages are already in shared
> buffers.

It's not hard to create a simple test case where it's about three
times slower to go to cached heap pages than to use the values from
the index. That was just my first try, so it's not likely to be a
real "worst case", although was using the default shared_memory
size, so a lot of the heap pages probably came from the OS cache,
rather than being in shared memory.

> But it matters a *lot* when they heap pages are not in shared
> buffers

Yeah, obviously it matters more if you actually need to add a random
disk read.

-Kevin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2011-10-12 15:30:00 Re: COUNT(*) and index-only scans
Previous Message Heikki Linnakangas 2011-10-12 15:24:33 Re: [BUGS] *.sql contrib files contain unresolvable MODULE_PATHNAME