Home / Function/ useQueryPerformanceQuery() — supabase Function Reference

useQueryPerformanceQuery() — supabase Function Reference

Architecture documentation for the useQueryPerformanceQuery() function in Reports.queries.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  9e669ea9_840f_2757_45f1_d42bb9496ead["useQueryPerformanceQuery()"]
  46403c67_1436_ec2c_d8a8_52c7ceb8118e["QueryPerformanceMetrics()"]
  46403c67_1436_ec2c_d8a8_52c7ceb8118e -->|calls| 9e669ea9_840f_2757_45f1_d42bb9496ead
  style 9e669ea9_840f_2757_45f1_d42bb9496ead fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/Reports/Reports.queries.ts lines 37–77

export const useQueryPerformanceQuery = ({
  preset,
  orderBy,
  searchQuery = '',
  roles,
  runIndexAdvisor = false,
  minCalls,
  minTotalTime,
  filterIndexAdvisor = false,
}: QueryPerformanceQueryOpts) => {
  const queryPerfQueries = PRESET_CONFIG[Presets.QUERY_PERFORMANCE]
  const baseSQL = queryPerfQueries.queries[preset]

  const whereSql = [
    roles !== undefined && roles.length > 0
      ? `auth.rolname in (${roles.map((r) => `'${r}'`).join(', ')})`
      : '',
    searchQuery.length > 0 ? `statements.query ~* '${searchQuery}'` : '',
    typeof minCalls === 'number' && minCalls > 0 ? `statements.calls >= ${minCalls}` : '',
    typeof minTotalTime === 'number' && minTotalTime > 0
      ? `(statements.total_exec_time + statements.total_plan_time) >= ${minTotalTime}`
      : '',
  ]
    .filter((x) => x.length > 0)
    .join(' AND ')

  const orderBySql = orderBy && `ORDER BY ${orderBy.column} ${orderBy.order}`
  const sql = baseSQL.sql(
    [],
    whereSql.length > 0 ? `WHERE ${whereSql}` : undefined,
    orderBySql,
    runIndexAdvisor,
    filterIndexAdvisor
  )
  return useDbQuery({
    sql,
    params: undefined,
    where: whereSql,
    orderBy: orderBySql,
  })
}

Subdomains

Frequently Asked Questions

What does useQueryPerformanceQuery() do?
useQueryPerformanceQuery() is a function in the supabase codebase.
What calls useQueryPerformanceQuery()?
useQueryPerformanceQuery() is called by 1 function(s): QueryPerformanceMetrics.

Analyze Your Own Codebase

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

Try Supermodel Free