pub struct Query<'a> { /* private fields */ }Expand description
A plan that has been built and is ready to run.
It borrows the plan and the catalog it was built from, which is what 'a is. A scan reads its
rows out of the catalog’s table rather than copying them and an expression reads its constants
out of the plan’s arena, so a query cannot outlive either.
Implementations§
Source§impl<'a> Query<'a>
impl<'a> Query<'a>
Sourcepub fn run(&self, cancel: &Cancel, pool: &Pool) -> Result<()>
pub fn run(&self, cancel: &Cancel, pool: &Pool) -> Result<()>
Runs every pipeline, stopping at the first one that fails.
Each one is timed against its own driver, which is the loop that runs a pipeline rather than any operator in it. That time is not nothing: on a scan of ten million rows the loop goes round ten thousand times, and none of it sits inside an operator’s own span, so without a driver it is time the metrics document cannot account for.
The lease is taken per pipeline and given back at the end of it, so a query whose scan uses nine threads and whose sort uses one holds nine for as long as the scan and one after that, and the threads it is not using are there for whatever else the database is running.
§Errors
Whatever any operator reports, or ErrorCode::Interrupt
if the token says to stop. The check is per chunk, in the driver, which is why no operator
here holds a token of its own except the join, whose nested loop can outlive a chunk.
Sourcepub fn worker_cpu_ns(&self) -> u64
pub fn worker_cpu_ns(&self) -> u64
CPU nanoseconds this query burned on threads other than the one that ran it.
A caller timing the execution reads its own thread’s CPU clock, which is the only clock there is that attributes work to the thread that did it, and which therefore cannot see the workers. This is what it missed.
Sourcepub fn widest(&self) -> usize
pub fn widest(&self) -> usize
The most instances any one pipeline of this query ran as.
Not the setting and not an average. A query whose scan ran on nine threads and whose sort ran on one reports nine, because the question this answers is what the query was able to use.
Sourcepub fn next_chunk(&self) -> Result<Option<Chunk>>
pub fn next_chunk(&self) -> Result<Option<Chunk>>
The next chunk of the answer, or None when there are no more.
Only meaningful after Query::run has returned. The serial driver runs a pipeline to
completion, so everything the query produced is queued by then, and taking a chunk here
removes it from the queue rather than copying it out.
§Errors
ErrorCode::Internal if a thread panicked while holding
the queue.
Sourcepub fn collect(&self, cancel: &Cancel, pool: &Pool) -> Result<Vec<Chunk>>
pub fn collect(&self, cancel: &Cancel, pool: &Pool) -> Result<Vec<Chunk>>
Runs the query and collects everything it produced.
The convenience the tests and the simple callers want. A caller that cares about holding one
chunk at a time calls Query::run and Query::next_chunk itself.
§Errors
The same as Query::run.