-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
74236: colfetcher,row: decode only needed columns when tracing is enabled r=yuzefovich a=yuzefovich **colfetcher: minor optimization when decoding the value part** Release note: None **colfetcher: fix recent bug of using wrong column with tracing in some cases** A couple of months ago when we taught the cFetcher to operate only on needed columns, we refactored the meaning of `ColIdxMap` - now it returns for the given ColumnID the ordinal of the column among all needed columns whereas previously it would return the ordinal among all columns in the table. In tracing we were relying on the old behavior to append the column name to the key part, and we mistakenly used the "needed" ordinal when accesing the "whole table" columns. This is now fixed. I noticed it while working on the next commit. Release note: None **colfetcher,row: decode only needed columns when tracing is enabled** In a recent change we made it so that the cFetcher would treat all columns present in the index as "needed" when the KV tracing is enabled. This led to some bugs (like reading of a virtual column that doesn't exist in the index) but is also not very meaningful since the goal of the tracing is to show what the cFetcher is doing without tracing. This commit starts treating the KV tracing as the request to log all needed operations without doing anything extra (like decoding unnecessary columns). A similar change is applied to the `row.Fetcher` as well. Fixes: #73745. Release note (sql change): The KV tracing of SQL queries (that could be obtained with `\set auto_trace=on,kv`) has been adjusted slightly. Previously, we would fully decode the key part of each key-value pair even if some part of the key would not be decoded when tracing is enabled. Now, we won't perform any extra decoding, and parts of the key that aren't decoded are replaced with `?`. **colfetcher: find needed columns upfront** Previously, the two users of the `cFetcher` (`ColBatchScan` and `ColIndexJoin`) had different ways of figuring out which columns are actually needed to be fetched (that information is needed to not decode parts of the KV pairs unnecessarily). In one case we explicitly propagated the information through the spec, and in another we did some pre-processing to find the information. This overall was more complicated than necessary (because we had complex code path for pruning "unaccessible" columns from the secondary index while keeping track of the ordinal mapping) as well as suboptimal (in some cases `TableReaderSpec.NeededColumns` contained ordinals of the columns that weren't actually needed by the post-processing stage), so this commit unifies both ways into one addressing both of these shortcomings. Now, in order to find the set of needed columns, we examine the post-processing spec all the time, but we do it in an efficient manner: - we make sure to deserialize render expressions early - we use a `tree.Visitor` rather than a heavy-weight `ExprHelper`. As a result, we can remove `TableReaderSpec.NeededColumns` field as well as not decode some columns in a handful of cases. Release note: None **sql: log undecoded values as <undecoded> in tracing** Previously, if the value part of a key-value pair wasn't needed, we would log it as `NULL`. However, that can be confusing whether an actual `NULL` value was decoded or not. This commit replaces the undecoded values with `<undecoded>` reducing the confusion (given that the likelihood of the value actually being equal to `<undecoded>` is negligible). Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
- Loading branch information
Showing
31 changed files
with
413 additions
and
566 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.