Re: Is there something wrong with my test case? - Mailing list pgsql-general

From Peter J. Holzer
Subject Re: Is there something wrong with my test case?
Date
Msg-id 20190106145217.7fxllfdeksgwvo35@hjp.at
Whole thread Raw
In response to Is there something wrong with my test case?  (Thiemo Kellner <thiemo@gelassene-pferde.biz>)
Responses Re: Is there something wrong with my test case?  (Thiemo Kellner <thiemo@gelassene-pferde.biz>)
List pgsql-general
On 2018-12-25 11:54:11 +0000, Thiemo Kellner wrote:
[three different but functionally equivalent queries]

> Explain analyze verbose showed for:
> A (cost=264.72..626.97 rows=31 width=90) (actual time=1.117..1.117 rows=0
> loops=1)
> B (cost=264.72..974.25 rows=31 width=58) (actual time=1.508..1.508 rows=0
> loops=1)
> C (cost=0.42..611.19 rows=31 width=52) (actual time=2.217..2.217 rows=0
> loops=1)
>
> I am very surprised that the cost of A is (much) higher than that of C which

626.97 doesn't seem "much higher" to me than 611.19. I would call that
"about the same".

> I suspected to be the most inefficient. I was that much fixed on the costs
> that I initially ignored the actual time where my assumptions on efficiency
> are reflected. Funny though is that the subjective impression when waiting
> for the update queries to complete was that C was fastest by far, followed
> by B and only at the end was update A.

This is weird. C takes almost exactly twice as long as A, and while
humans aren't very good at estimating times, One second should feel
faster than two, not slower, and certainly not slower by far. Is it
possible that your subjective impression wasn't based on the executions
you posted but on others? Caching and load spikes can cause quite large
variations in run time, so running the same query again may not take the
same time (usually the second time is faster - sometimes much faster).

        hp

--
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp@hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>

Attachment

pgsql-general by date:

Previous
From: Thiemo Kellner
Date:
Subject: Is it impolite to dump a message
Next
From: Stephen Frost
Date:
Subject: Re: Is it impolite to dump a message