File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
rust/cubestore/cubestore/src Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ pub static DATA_QUERY_CREATE_ROUTER_PHYSICAL_PLAN_US: Histogram =
5353pub static DATA_QUERY_CREATE_WORKER_PHYSICAL_PLAN_US : Histogram =
5454 metrics:: histogram ( "cs.sql.query.data.planning.worker_plan.us" ) ;
5555
56+ pub static SQL_QUERY_DATA_FRAME_SERIALIZATION_TIME_US : Histogram =
57+ metrics:: histogram ( "cs.sql.query.data_frame_serialization.us" ) ;
58+
5659/// Incoming SQL queries that only read metadata or do trivial computations.
5760pub static META_QUERIES : Counter = metrics:: counter ( "cs.sql.query.meta" ) ;
5861pub static META_QUERY_TIME_MS : Histogram = metrics:: histogram ( "cs.sql.query.meta.ms" ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use crate::config::processing_loop::ProcessingLoop;
22use crate :: sql:: { InlineTables , SqlQueryContext , SqlService } ;
33use crate :: table:: TableValue ;
44use crate :: util:: time_span:: warn_long;
5- use crate :: { metastore, CubeError } ;
5+ use crate :: { app_metrics , metastore, CubeError } ;
66use async_trait:: async_trait;
77use datafusion:: cube_ext;
88use hex:: ToHex ;
@@ -78,6 +78,9 @@ impl<W: io::Write + Send> AsyncMysqlShim<W> for Backend {
7878 }
7979 let _s = warn_long ( "sending query results" , Duration :: from_millis ( 100 ) ) ;
8080 let data_frame = res. unwrap ( ) ;
81+
82+ let data_frame_serialization_start_time = SystemTime :: now ( ) ;
83+
8184 let columns = data_frame
8285 . get_columns ( )
8386 . iter ( )
@@ -133,7 +136,20 @@ impl<W: io::Write + Send> AsyncMysqlShim<W> for Backend {
133136 rw. end_row ( ) ?;
134137 }
135138 rw. finish ( ) ?;
136- if start. elapsed ( ) . unwrap ( ) . as_millis ( ) > 200 && query. to_lowercase ( ) . starts_with ( "select" )
139+
140+ let end_time = SystemTime :: now ( ) ;
141+ app_metrics:: SQL_QUERY_DATA_FRAME_SERIALIZATION_TIME_US . report (
142+ end_time
143+ . duration_since ( data_frame_serialization_start_time)
144+ . unwrap_or_default ( )
145+ . as_micros ( ) as i64 ,
146+ ) ;
147+ if end_time
148+ . duration_since ( start)
149+ . unwrap_or_default ( )
150+ . as_millis ( )
151+ > 200
152+ && query. to_lowercase ( ) . starts_with ( "select" )
137153 {
138154 warn ! (
139155 "Slow Query SQL ({:?}):\n {}" ,
You can’t perform that action at this time.
0 commit comments