From: Craig A. James <cjames@modgraph-usa.com>
To: pgsql-performance@postgresql.org
Subject: Re: Used Memory
Date: Mon, 24 Oct 2005 10:00:04 -0700
Message-ID: <435D1314.5040807@modgraph-usa.com> (raw)
In-Reply-To: <435CBC9202000025000001AB@gwmta.wicourts.gov>
References: <435CBC9202000025000001AB@gwmta.wicourts.gov>
Kevin Grittner wrote:
> In addition to what Mark pointed out, there is the possibility that a
> query
> is running which is scanning a large table or otherwise bringing in a
> large number of pages from disk. That would first use up all available
> unused cache space, and then may start replacing some of your
> frequently used data.
An LRU cache is often a bad strategy for database applications. There are two illustrations that show why.
1. You have an index that's used for EVERY search, but each search returns a large and unique set of rows. If it happens that the rows returned exceed the systems cache size, the part or all of your index will be flushed with EVERY query.
2. You do a sequential scan of a table that's one block bigger than the file system cache, then you do it again. At the beginning of the second scan, the first block of the table will have just been swapped out because it was the oldest, so the file system brings it back in, replacing the second block, which is now the oldest. As you scan the table, each block of the table is swapped out JUST BEFORE you get to it. At the start of your query, the file system might have had 99.9% of the relevant data in memory, but it swaps out 100% of it as your query progresses.
Scenario 2 above is interesting because a system that is performing very well can suddenly experience a catastrophic performance decline when the size of the data exceeds a critical limit - the file system's avaliable cache.
LRU works well if your frequently-used data is used often enough to keep it in memory. But many applications don't have that luxury. It's often the case that a single query will exceed the file system's cache size. The file system cache is "dumb" -- it's strategy is too simple for a relational database.
What's needed is a way for the application developer to explicitely say, "This object is frequenly used, and I want it kept in memory."
Craig
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: cjames@modgraph-usa.com
Subject: Re: Used Memory
In-Reply-To: <435D1314.5040807@modgraph-usa.com>
* 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