Home / Function/ transformStatementDataToRows() — supabase Function Reference

transformStatementDataToRows() — supabase Function Reference

Architecture documentation for the transformStatementDataToRows() function in WithStatements.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  1986cdbd_1b6f_c5c3_ad56_895d25013fca["transformStatementDataToRows()"]
  1062988d_666a_109e_9846_15b701cc0d74["WithStatements()"]
  1062988d_666a_109e_9846_15b701cc0d74 -->|calls| 1986cdbd_1b6f_c5c3_ad56_895d25013fca
  9643ffdc_72a7_4e8b_0cb9_9dd31e6c10ed["filterProtectedSchemaIndexAdvisorResult()"]
  1986cdbd_1b6f_c5c3_ad56_895d25013fca -->|calls| 9643ffdc_72a7_4e8b_0cb9_9dd31e6c10ed
  6e7b031c_d72f_c376_fdd0_a519f4b1bb66["queryInvolvesProtectedSchemas()"]
  1986cdbd_1b6f_c5c3_ad56_895d25013fca -->|calls| 6e7b031c_d72f_c376_fdd0_a519f4b1bb66
  style 1986cdbd_1b6f_c5c3_ad56_895d25013fca fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/QueryPerformance/WithStatements/WithStatements.utils.ts lines 7–47

export const transformStatementDataToRows = (
  data: any[],
  filterIndexAdvisor: boolean = false
): QueryPerformanceRow[] => {
  if (!data || data.length === 0) return []

  const totalTimeAcrossAllQueries = data.reduce((sum, row) => sum + (row.total_time || 0), 0)

  return data
    .map((row) => {
      const filteredIndexAdvisorResult = row.index_advisor_result
        ? filterProtectedSchemaIndexAdvisorResult(row.index_advisor_result)
        : null

      return {
        query: row.query,
        rolname: row.rolname || undefined,
        calls: row.calls || 0,
        mean_time: row.mean_time || 0,
        min_time: row.min_time || 0,
        max_time: row.max_time || 0,
        total_time: row.total_time || 0,
        rows_read: row.rows_read || 0,
        cache_hit_rate: row.cache_hit_rate || 0,
        prop_total_time:
          totalTimeAcrossAllQueries > 0 ? (row.total_time / totalTimeAcrossAllQueries) * 100 : 0,
        index_advisor_result: filteredIndexAdvisorResult,
      }
    })
    .filter((row) => {
      if (filterIndexAdvisor) {
        const hasValidRecommendations = row.index_advisor_result !== null
        const involvesProtectedSchemas = queryInvolvesProtectedSchemas(row.query)

        if (involvesProtectedSchemas && !hasValidRecommendations) {
          return false
        }
      }
      return true
    })
}

Subdomains

Called By

Frequently Asked Questions

What does transformStatementDataToRows() do?
transformStatementDataToRows() is a function in the supabase codebase.
What does transformStatementDataToRows() call?
transformStatementDataToRows() calls 2 function(s): filterProtectedSchemaIndexAdvisorResult, queryInvolvesProtectedSchemas.
What calls transformStatementDataToRows()?
transformStatementDataToRows() is called by 1 function(s): WithStatements.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free