2 ms·
So here is a little bit of explanation (which it sounds like you may already know). The general reason is that the cost reflects a lot of factors, and, if numbe
by willj 8y ago
So here is a little bit of explanation (which it sounds like you may already know). The general reason is that the cost reflects a lot of factors, and, if number of rows + available resources (CPU, memory, IO) + locks are constant, for the same logical result set, the cost does map to wall time. For example, given those constants I mentioned, if the execution time for a cost of 100 is 10 minutes, then you tweak the query (getting the same logical results) and the new cost is 50, the new execution time would be ~5 minutes (I think).
But most of those things I mentioned aren't constant. Available resources/system load changes, number of rows in tables change, and # of locks and length of holding on rows/tables change. So what you're left with is a cost that reflects the relative performance of a query compared to the same result set obtained by a different query.
For reference, in Oracle, this SO link [1] explains how cost is calculated.
Note: this is all my understanding, and someone more knowledgeable might know better.
[1] https://stackoverflow.com/a/8177490 https://stackoverflow.com/a/8177490