comdb2
comdb2 copied to clipboard
Return cost components as json; add getter cdb2_get_info()
Include statement cost and extended cost as part of lastresponse so we avoid extra call to the db to get cost.
- Always return numeric value of cost
- If get_cost is set, return extended cost info--cost components
-
cdb2sql --cost
prints extended cost as json string using cdb2api getter function cdb2_get_info()
Example json extended cost from cdb2sql:
> cdb2sql adidb -cost 'select moredata from t2 where uid in (select uid from t1 where i=2)' | tail +2
{"Cost":32.40,"NumRows":1,
"Components": [
{"Type":"Table Scan","Table":"t1","NumFind":1,"NumNextOrPrev":1},
{"Type":"Table Scan","Table":"t2","NumFind":1},
{"Type":"Index Lookup","Index":0,"Table":"t2","NumFind":1,"NumNextOrPrev":1},
{"Type":"Temp Index Lookup","NumFind":1,"NumPrevOrNext":1,"NumWrites":1 }
]}
Signed-off-by: Adi Zaimi [email protected]