Reputation: 357
Is there any way to check if index is loaded to memory?
Upvotes: 5
Views: 5639
Reputation: 18136
Note that PostgreSQL can't execute queries just based on the index data. It has to visit the data in order to determine what information is visible from the perspective of the query; that information is only in the rows themselves, not in the index. It's quite possible the index is all in RAM, but you're still seeing heavy I/O because the table doesn't fit there.
Upvotes: 2
Reputation: 36729
Use PgFincore for that.
Note that this question really has a two step solution because PostgreSQL has a two-level caching mechanism. pg_buffercache is the right tool for examining the PostgreSQL shared buffer cache. pgfincore is the right tool for examining the operating system's cache.
Upvotes: 1
Reputation: 127056
Check the contrib module pg_buffercache
After installation you can use this query to see if the table and index are in the buffercache:
SELECT
DISTINCT
relname
FROM
pg_buffercache
JOIN pg_class USING (relfilenode)
WHERE
relname IN('your_tablename','your_index_name');
Upvotes: 5