pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Mackay <mackaypaul@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Index on function less well cached than "regular" index ?
Date: Mon, 24 Apr 2006 12:53:29 +0200
Message-ID: <786c2f6d0604240353n7853ef1fn148611ed2674044c@mail.gmail.com> (raw)

I have a table of ~ 41 000 rows with an index on the result of a function
applied to a certain text column (the function basically removes "neutral"
or common words like "the","on","a", etc. from the string).

I then execute a query with a where clause on this function result with an
order by on the function result also and a limit of 200. Logically the
EXPLAIN shows that an index scan is used by the planner. A query returning
the maximum 200 number of records takes around 20 ms. What is surprising is
that the same query executed several times takes practically the same time,
as if the result was not cached.

To test this, I then added a new text column to the same table, populating
it with the function result mentioned above. Now, I create an index on this
new column and execute the same query as described above (order by on the
new column and limit 200). The execution plan is exactly the same, except
that the new index is used of course. The first execution time is similar,
i.e. 20 ms approx., but the next executions of the same query take about 2
ms (i.e to say a 10 to 1 difference). So this time, it seems that the result
is properly cached.

Could the problem be that an index on a function result is not cached or
less well cached ?

Thanks,
Paul

view thread (2+ messages)  latest in thread

Message-ID: <786c2f6d0604240353n7853ef1fn148611ed2674044c@mail.gmail.com>
Permalink:  ../786c2f6d0604240353n7853ef1fn148611ed2674044c@mail.gmail.com/
Also on:    postgresql.org/message-id/786c2f6d0604240353n7853ef1fn148611ed2674044c@mail.gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: mackaypaul@gmail.com
  Subject: Re: Index on function less well cached than "regular" index ?
  In-Reply-To: <786c2f6d0604240353n7853ef1fn148611ed2674044c@mail.gmail.com>
  References: <786c2f6d0604240353n7853ef1fn148611ed2674044c@mail.gmail.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