FirebirdSQL / firebird

Firebird server, client and tools
https://www.firebirdsql.org/
1.23k stars 213 forks source link

Include COST for statement in mon$statements [CORE4207] #4532

Open firebird-automations opened 11 years ago

firebird-automations commented 11 years ago

Submitted by: @sim1984

Votes: 1

In some cases it would be useful to have an estimate of the cost in a separate column of the table mon$statements. This extends the ticket CORE2303. This would allow, for example, learn the 10 most costly in terms of cost requests.

select * from mon$statements order by mon$statements.mon$cost desc rows 10

firebird-automations commented 11 years ago
Modified by: @sim1984 priority: Major \[ 3 \] =\> Minor \[ 4 \]
firebird-automations commented 11 years ago

Commented by: @dyemanov

Cost is an estimation used by the optimizer. It exists for retrievals, but it doesn't exist for modifications and some CPU bound operations like loops or condition evaluations. What should be returned as a cost for UPDATE then - cost of its underlying select or something wider?

If you're talking about actual (not estimated) costs, they're more or less reflected in MON$RECORD_STATS for the every attachment, so it's quite easy to get top 10 of the heaviest requests currently running.

firebird-automations commented 11 years ago

Commented by: @sim1984

I mean it was estimated value, which seems to be planned output in the extended query plan.

firebird-automations commented 10 years ago
Modified by: @dyemanov assignee: Dmitry Yemanov \[ dimitr \]