Is there a postgresql equivalent for the MySQL keyword SQL_NO_CACHE
(or the SQL Server dbcc drop clean buffers
) i.e. which you can simply include in a SQL statement or as part of a script?
UPDATE: this question
See and clear Postgres caches/buffers?
seems to say that the answer is "no", although it is now two years old. Are there any relevant changes in postgresql 9.0?
PostgreSQL caches the following for accelerating data access: Data in tables. Indexes. Query execution plans.
The DISCARD ALL statement discards the session state. It discards all temporary tables, plans, and sequences, along with any session-specific configurations. This statement is often used by connection poolers before reusing the connection for the next client.
The two things you've stated are not at all equivalent.
MySQL's SQL_NO_CACHE does NOT stop the engine from using cached data. It means that the query is not cached in the MySQL query cache.
The query cache is not the same as any disc cache the engine might have because it caches the results of queries, not blocks from the disc (or rows from a table etc). So it caches the results of a text statement.
The reason for using SQL_NO_CACHE is that you know you're going to be doing an infrequently-used query which returns a lot of data (hence would take up a lot of space in the cache).
But most MySQL installations are now advised to turn the query cache off to make more memory for page caches etc (see http://dom.as/tech/query-cache-tuner/ )
No need for, cache in PostgreSQL works very different and is 100% reliable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With