Skip to content

Commit

Permalink
[GraphQL/DB] Debug print query
Browse files Browse the repository at this point in the history
## Description

Use a `debug!` trace to print the query during estimation.

## Test plan

```
sui$ RUST_LOG=debug cargo run --bin sui-graphql-rpc -- ...
```
  • Loading branch information
amnn committed May 14, 2024
1 parent 0673eb4 commit 2822fad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/sui-graphql-rpc/src/data/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ mod query_cost {
use diesel::{query_builder::AstPass, sql_types::Text, PgConnection, QueryResult};
use serde_json::Value;
use tap::{TapFallible, TapOptional};
use tracing::{info, warn};
use tracing::{debug, info, warn};

#[derive(Debug, Clone, Copy, QueryId)]
struct Explained<Q> {
Expand All @@ -151,6 +151,8 @@ mod query_cost {
where
Q: Query + QueryId + QueryFragment<Pg> + RunQueryDsl<PgConnection>,
{
debug!("Estimating: {}", diesel::debug_query(&query).to_string());

let Some(cost) = explain(conn, query) else {
warn!("Failed to extract cost from EXPLAIN.");
return;
Expand Down

0 comments on commit 2822fad

Please sign in to comment.