Thanks Eric and Gaestano - interesting, and both examples of my naivite. :)

I tried running large select(*) queries on other tables followed by another try at the offending query, and it was still fast. Just to be absolutely sure this is a scalable solution, I'll try restarting my computer in a few hours to see if it affects anything cache-wise.


Gaetano Mendola wrote:
John Beaver wrote:

  
- Trying the same constant a second time gave an instantaneous result,
I'm guessing because of query/result caching.
    

AFAIK no query/result caching is in place in postgres, what you are experiencing
is OS disk/memory caching.


Regards
Gaetano Mendola