I have a query that takes around 1 second on first execution and 15-50 ms after running the same query again. The only difference between EXPLAIN outputs is that the second execution contains a lot of
Buffers: shared hit which are probably (and correct me if I'm wrong) responsible for the noticeable speed up.
So I was wondering, when people talk about queries taking x milliseconds, are they usually referring to the time it takes on first execution?
Do you care about a slow query that after caching is actually quite fast? This assumes that your application requires reasonable response times (e.g. e-commerce, real-time analytics, etc).
I'm using PostgreSQL 9.5, but I intended to ask something general enough to be widely useful.