Re: UPDATEDs slowing SELECTs in a fully cached database

From: lars <lhofhansl(at)yahoo(dot)com>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: Ivan Voras <ivoras(at)freebsd(dot)org>, pgsql-performance(at)postgresql(dot)org
Subject: Re: UPDATEDs slowing SELECTs in a fully cached database
Date: 2011-07-12 20:04:57
Message-ID: 4E1CA8E9.6090108@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 07/12/2011 12:08 PM, Kevin Grittner wrote:
> lars<lhofhansl(at)yahoo(dot)com> wrote:
>
>> select count(*) from test where tenant = $1 and created_date = $2
>
> Ah, that might be a major clue -- prepared statements.
>
> What sort of a plan do you get for that as a prepared statement?
> (Note, it is very likely *not* to be the same plan as you get if you
> run with literal values!) It is not at all unlikely that it could
> resort to a table scan if you have one tenant which is five or ten
> percent of the table, which would likely trigger the pruning as it
> passed over the modified pages.
>
> -Kevin
So a read of a row *will* trigger dead tuple pruning, and that requires
WAL logging, and this is known/expected?
This is actually the only answer I am looking for. :) I have not seen
this documented anywhere.

I know that Postgres will generate general plans for prepared statements
(how could it do otherwise?),
I also know that it sometimes chooses a sequential scan.
This can always be tweaked to touch fewer rows and/or use a different
plan. That's not my objective, though!

The fact that a select (maybe a big analytical query we'll run) touching
many rows will update the WAL and wait
(apparently) for that IO to complete is making a fully cached database
far less useful.
I just artificially created this scenario.

... Just dropped the table to test something so I can't get the plan
right now. Will send an update as soon as I get
it setup again.

Thanks again.

-- Lars

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Kevin Grittner 2011-07-12 20:51:24 Re: UPDATEDs slowing SELECTs in a fully cached database
Previous Message Tom Lane 2011-07-12 20:04:12 Re: Planner choosing NestedLoop, although it is slower...