Skip to main content

summary

Function summary 

Source
pub fn summary(statement: &str, truncate_limit: i32) -> Result<SummaryResult>
Expand description

Parses the given SQL statement and provides a summary of it.

It is possible to generate the same data using pg_query::parse and iterating through the parse tree. However, pg_query::summary uses a C implementation to avoid sending as much data over protobuf.

Avoiding sending the parse tree over protobuf can cause as much as an order of magnitude performance improvement. It also prevents some crashes caused by protobuf handling such a large amount of data.

You can run cargo bench parse_vs_summary to run the benchmarks that comparse the two options.

ยงExample

use pg_query::{Node, NodeEnum, NodeRef};

let result = pg_query::summary("SELECT * FROM contacts", -1);
assert!(result.is_ok());
let result = result.unwrap();
assert_eq!(result.tables(), vec!["contacts"]);