The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
updated text across all the report. using react markdown. added typography tailwind config
Jonathan Summers-Muir15158aa4a73a
diff --git a/studio/components/interfaces/Reports/Reports.constants.ts b/studio/components/interfaces/Reports/Reports.constants.tsindex 3713345e5f5..17183a514bc 100644--- a/studio/components/interfaces/Reports/Reports.constants.ts+++ b/studio/components/interfaces/Reports/Reports.constants.ts@@ -242,6 +242,90 @@ order by},},},+ [Presets.QUERY_PERFORMANCE]: {+ title: 'Query performance',+ queries: {+ mostFrequentlyInvoked: {+ queryType: 'db',+ sql: (_params) => `+-- Most frequently called queries+-- A limit of 100 has been added below+select+ auth.rolname,+ statements.query,+ statements.calls,+ -- -- Postgres 13, 14, 15+ statements.total_exec_time + statements.total_plan_time as total_time,+ statements.min_exec_time + statements.min_plan_time as min_time,+ statements.max_exec_time + statements.max_plan_time as max_time,+ statements.mean_exec_time + statements.mean_plan_time as mean_time,+ -- -- Postgres <= 12+ -- total_time,+ -- min_time,+ -- max_time,+ -- mean_time,+ statements.rows / statements.calls as avg_rows+ from pg_stat_statements as statements+ inner join pg_authid as auth on statements.userid = auth.oid+ order by+ statements.calls desc+ limit 10;`,+ },+ mostTimeConsuming: {+ queryType: 'db',+ sql: (_params) => `-- A limit of 100 has been added below+select+ auth.rolname,+ statements.query,+ statements.calls,+ statements.total_exec_time + statements.total_plan_time as total_time,+ to_char(((statements.total_exec_time + statements.total_plan_time)/sum(statements.total_exec_time + statements.total_plan_time) OVER()) * 100, 'FM90D0') || '%' AS prop_total_time+ from pg_stat_statements as statements+ inner join pg_authid as auth on statements.userid = auth.oid+ order by+ total_time desc+ limit 10;`,+ },+ slowestExecutionTime: {+ queryType: 'db',+ sql: (_params) => `-- Slowest queries by max execution time+-- A limit of 100 has been added below+select+ auth.rolname,+ statements.query,+ statements.calls,+ -- -- Postgres 13, 14, 15+ statements.total_exec_time + statements.total_plan_time as total_time,+ statements.min_exec_time + statements.min_plan_time as min_time,+ statements.max_exec_time + statements.max_plan_time as max_time,+ statements.mean_exec_time + statements.mean_plan_time as mean_time,+ -- -- Postgres <= 12+ -- total_time,+ -- min_time,+ -- max_time,+ -- mean_time,+ statements.rows / statements.calls as avg_rows+ from pg_stat_statements as statements+ inner join pg_authid as auth on statements.userid = auth.oid+ order by+ max_time desc+ limit 10`,+ },+ queryHitRate: {+ queryType: 'db',+ sql: (_params) => `-- Cache and index hit rate+select+ 'index hit rate' as name,+ (sum(idx_blks_hit)) / nullif(sum(idx_blks_hit + idx_blks_read),0) as ratio+ from pg_statio_user_indexes+ union all+ select+ 'table hit rate' as name,+ sum(heap_blks_hit) / nullif(sum(heap_blks_hit) + sum(heap_blks_read),0) as ratio+ from pg_statio_user_tables;`,+ },+ },+ },}export const DATETIME_FORMAT = 'MMM D, ha'diff --git a/studio/components/interfaces/Reports/Reports.types.ts b/studio/components/interfaces/Reports/Reports.types.tsindex 0cc81dd470e..af6ca322b0a 100644--- a/studio/components/interfaces/Reports/Reports.types.ts+++ b/studio/components/interfaces/Reports/Reports.types.ts@@ -4,6 +4,7 @@ import { DEFAULT_QUERY_PARAMS } from './Reports.constants'export enum Presets {API = 'api',AUTH = 'auth',+ QUERY_PERFORMANCE = 'query_performance',}export interface QueryDataBase {diff --git a/studio/components/interfaces/Reports/Reports.utils.tsx b/studio/components/interfaces/Reports/Reports.utils.tsxindex 006ee0e17d5..507176c6cc1 100644--- a/studio/components/interfaces/Reports/Reports.utils.tsx+++ b/studio/components/interfaces/Reports/Reports.utils.tsx@@ -64,16 +64,24 @@ export const usePresetReport = (hooks: PresetHookResult[]) => {}const isLoading = data.map((datum) => datum.isLoading).some((v) => v)- const Layout: React.FC<{ title: string }> = ({ title, children }) => (+ const Layout: React.FC<{ title: string; showDatePickers?: boolean }> = ({+ title,+ showDatePickers = true,+ children,+ }) => (<div className="flex flex-col gap-4 px-5 py-6 mx-auto 1xl:px-28 lg:px-16 xl:px-24 2xl:px-32"><h1 className="text-2xl text-scale-1200">{title}</h1><div className="flex flex-row justify-between">- <DatePickers- onChange={handleDatepickerChange}- to={data[0]?.params?.iso_timestamp_end || ''}- from={data[0]?.params?.iso_timestamp_start || ''}- helpers={REPORTS_DATEPICKER_HELPERS}- />+ <div>+ {showDatePickers && (+ <DatePickers+ onChange={handleDatepickerChange}+ to={data[0]?.params?.iso_timestamp_end || ''}+ from={data[0]?.params?.iso_timestamp_start || ''}+ helpers={REPORTS_DATEPICKER_HELPERS}+ />+ )}+ </div><Buttontype="default"size="tiny"diff --git a/studio/pages/project/[ref]/reports/query-performance.tsx b/studio/pages/project/[ref]/reports/query-performance.tsxindex 506ca90cd0e..2dc511caaa1 100644--- a/studio/pages/project/[ref]/reports/query-performance.tsx+++ b/studio/pages/project/[ref]/reports/query-performance.tsx@@ -1,154 +1,49 @@-import { observer } from 'mobx-react-lite'-import { NextPageWithLayout } from 'types'+import { PRESET_CONFIG } from 'components/interfaces/Reports/Reports.constants'+import { Presets } from 'components/interfaces/Reports/Reports.types'+import { hooksFactory, usePresetReport } from 'components/interfaces/Reports/Reports.utils'import { ReportsLayout } from 'components/layouts'-import { Button, Tabs, Accordion, IconInfo } from 'ui'-import useDbQuery from 'hooks/analytics/useDbQuery'-import Table from 'components/to-be-cleaned/Table'-import { IconAlertCircle, IconCheckCircle } from '@supabase/ui'-import { executeSql } from 'data/sql/execute-sql-query'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'+import Table from 'components/to-be-cleaned/Table'import CopyButton from 'components/ui/CopyButton'-import { useFlag } from 'hooks'import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog'+import { executeSql } from 'data/sql/execute-sql-query'+import { useFlag } from 'hooks'+import { observer } from 'mobx-react-lite'+import { useRouter } from 'next/router'import { useState } from 'react'-import { ReactMarkdown } from 'react-markdown/lib/react-markdown'--const limit = 10--const QueryMostFrequentlyInvoked = `--- Most frequently called queries--- A limit of 100 has been added below-select- auth.rolname,- statements.query,- statements.calls,- -- -- Postgres 13, 14, 15- statements.total_exec_time + statements.total_plan_time as total_time,- statements.min_exec_time + statements.min_plan_time as min_time,- statements.max_exec_time + statements.max_plan_time as max_time,- statements.mean_exec_time + statements.mean_plan_time as mean_time,- -- -- Postgres <= 12- -- total_time,- -- min_time,- -- max_time,- -- mean_time,- statements.rows / statements.calls as avg_rows- from pg_stat_statements as statements- inner join pg_authid as auth on statements.userid = auth.oid- order by- statements.calls desc- limit- ${limit};`--const QueryMostTimeConsuming = `-- Most time consuming queries--- A limit of 100 has been added below-select- auth.rolname,- statements.query,- statements.calls,- statements.total_exec_time + statements.total_plan_time as total_time,- to_char(((statements.total_exec_time + statements.total_plan_time)/sum(statements.total_exec_time + statements.total_plan_time) OVER()) * 100, 'FM90D0') || '%' AS prop_total_time- from pg_stat_statements as statements- inner join pg_authid as auth on statements.userid = auth.oid- order by- total_time desc- limit ${limit};`--const QuerySlowestExecutionTime = `-- Slowest queries by max execution time--- A limit of 100 has been added below-select- auth.rolname,- statements.query,- statements.calls,- -- -- Postgres 13, 14, 15- statements.total_exec_time + statements.total_plan_time as total_time,- statements.min_exec_time + statements.min_plan_time as min_time,- statements.max_exec_time + statements.max_plan_time as max_time,- statements.mean_exec_time + statements.mean_plan_time as mean_time,- -- -- Postgres <= 12- -- total_time,- -- min_time,- -- max_time,- -- mean_time,- statements.rows / statements.calls as avg_rows- from pg_stat_statements as statements- inner join pg_authid as auth on statements.userid = auth.oid- order by- max_time desc- limit- ${limit};-`--const QueryHitRate = `-- Cache and index hit rate-select- 'index hit rate' as name,- (sum(idx_blks_hit)) / nullif(sum(idx_blks_hit + idx_blks_read),0) as ratio- from pg_statio_user_indexes- union all- select- 'table hit rate' as name,- sum(heap_blks_hit) / nullif(sum(heap_blks_hit) + sum(heap_blks_read),0) as ratio- from pg_statio_user_tables;-`+import ReactMarkdown from 'react-markdown'+import { NextPageWithLayout } from 'types'+import { Accordion, Button, IconAlertCircle, IconCheckCircle, Tabs } from 'ui'const QueryPerformanceReport: NextPageWithLayout = () => {- const QueryMostFrequentlyInvokedData = useDbQuery(QueryMostFrequentlyInvoked)- const QueryMostTimeConsumingData = useDbQuery(QueryMostTimeConsuming)- const QuerySlowestExecutionTimeData = useDbQuery(QuerySlowestExecutionTime)- const QueryHitRateData = useDbQuery(QueryHitRate)const { project } = useProjectContext()- const [showResetgPgStatStatements, setShowResetgPgStatStatements] = useState(false)+ const router = useRouter()+ const { ref } = router.query+ const [showResetgPgStatStatements, setShowResetgPgStatStatements] = useState(false)const tableIndexEfficiencyEnabled = useFlag('tableIndexEfficiency')- const isLoadedQueryMostFrequentlyInvokedData =- QueryMostFrequentlyInvokedData &&- QueryMostFrequentlyInvokedData.length > 0 &&- QueryMostFrequentlyInvokedData[0] &&- QueryMostFrequentlyInvokedData[0].data- ? true- : false- const isLoadedQueryMostTimeConsumingData =- QueryMostTimeConsumingData &&- QueryMostTimeConsumingData.length > 0 &&- QueryMostTimeConsumingData[0] &&- QueryMostTimeConsumingData[0].data- ? true- : false- const isLoadedQuerySlowestExecutionTimeData =- QuerySlowestExecutionTimeData &&- QuerySlowestExecutionTimeData.length > 0 &&- QuerySlowestExecutionTimeData[0] &&- QuerySlowestExecutionTimeData[0].data- ? true- : false- const isLoadedQueryHitRateData =- QueryHitRateData &&- QueryHitRateData.length > 0 &&- QueryHitRateData[0] &&- QueryHitRateData[0].data- ? true- : false+ const config = PRESET_CONFIG[Presets.QUERY_PERFORMANCE]+ const hooks = hooksFactory(ref as string, config)+ const mostFrequentlyInvoked = hooks.mostFrequentlyInvoked()+ const mostTimeConsuming = hooks.mostTimeConsuming()+ const slowestExecutionTime = hooks.slowestExecutionTime()+ const queryHitRate = hooks.queryHitRate()++ const { isLoading, Layout } = usePresetReport([+ mostFrequentlyInvoked,+ mostTimeConsuming,+ slowestExecutionTime,+ queryHitRate,+ ])- if (isLoadedQueryMostFrequentlyInvokedData) {- console.log('QueryMostFrequentlyInvokedData', QueryMostFrequentlyInvokedData)- }- if (isLoadedQueryMostTimeConsumingData) {- console.log('QueryMostTimeConsumingData', QueryMostTimeConsumingData)- }- if (isLoadedQuerySlowestExecutionTimeData) {- console.log('QuerySlowestExecutionTimeData', QuerySlowestExecutionTimeData)- }- if (isLoadedQueryHitRateData) {- console.log('QueryHitRateData', QueryHitRateData)- }+ console.log('ziinc mostFrequentlyInvoked', mostFrequentlyInvoked)const checkAlert = (<div className="w-5 h-5 text-brand-1400 text-brand-900 flex items-center justify-center"><IconCheckCircle strokeWidth={2} size={16} /></div>)-const warnAlert = (<div className="w-6 h-6 text-yellow-900 flex items-center justify-center"><IconAlertCircle strokeWidth={2} size={16} />@@ -160,15 +55,39 @@ const QueryPerformanceReport: NextPageWithLayout = () => {</div>)- const indexHitRate = QueryHitRateData[0]?.data?.[0]?.ratio- const tableHitRate = QueryHitRateData[0]?.data?.[1]?.ratio+ const indexHitRate = queryHitRate[0]?.data?.[0]?.ratio+ const tableHitRate = queryHitRate[0]?.data?.[1]?.ratioconst showIndexWarning =indexHitRate && tableHitRate && (indexHitRate <= 0.99 || tableHitRate <= 0.99)- return (- <>- <h1 className="text-4xl">Query performance</h1>+ const text = `This report will help you identify and understand queries that take the most time and resources+ from your database.++ You can read more about [query performance](https://supabase.com/docs/guides/platform/performance#examining-query-performance)+ in our docs.++ You may also want to reset this analysis when you are optimizing your queries. This analysis is based on the extensions.pg_stat_statements table, so this table will be cleared when resetting.+ `++ const TimeConsumingHelperText = `This report will show you statistics about queries ordered by the cumulative total execution time.+ It shows the total time the query has spent running as well as the proportion of total execution time the query has taken up.+ `+ const MostFrequentHelperText = `This report is ordered by the number of times each query has been executed.++This provides useful information about the queries you run most frequently. Queries that have high max_time or mean_time times and are being called often can be good candidates for optimization.+ `++ const SlowestExecutionHelperText = `This report will show you statistics about queries ordered by the maximum execution time.++ It is similar to the 'Most freqeunt' report ordered by calls, but this one highlights outliers that may have high executions times. Queries which have high or mean execution times are good candidates for optimisation.+ `++ const panelClassNames = 'text-sm max-w-none flex flex-col gap-8 py-4'+ const helperTextClassNames = 'prose text-sm max-w-3xl text-scale-1000'++ return (+ <Layout title="Query Performance" showDatePickers={false}>{tableIndexEfficiencyEnabled && (<AccordionopenBehaviour="multiple"@@ -185,7 +104,7 @@ const QueryPerformanceReport: NextPageWithLayout = () => {id="1"className="flex flex-row gap-8">- {isLoadedQueryHitRateData && (+ {!isLoading && queryHitRate && (<div><div className="flex flex-row px-8 py-4 gap-8"><div className="w-1/2 bg-slate-200 rounded-md p-4">@@ -198,7 +117,7 @@ const QueryPerformanceReport: NextPageWithLayout = () => {: dangerAlert}<div className="flex items-baseline"><span className="text-3xl">- {(QueryHitRateData[0]?.data[0]?.ratio * 100).toFixed(2)}+ {(queryHitRate[0]?.data![0]?.ratio * 100).toFixed(2)}</span><span className="text-xl">%</span></div>@@ -206,7 +125,7 @@ const QueryPerformanceReport: NextPageWithLayout = () => {</div><div className="w-1/2 bg-slate-200 rounded-md p-4">- {QueryHitRateData[0]?.data[1]?.name == 'table hit rate' && 'Table Hit Rate'}+ {queryHitRate[0]?.data![1]?.name == 'table hit rate' && 'Table Hit Rate'}<div className="flex items-center gap-2">{tableHitRate >= 0.99? checkAlert@@ -215,7 +134,7 @@ const QueryPerformanceReport: NextPageWithLayout = () => {: dangerAlert}<div className="flex items-baseline"><span className="text-3xl">- {(QueryHitRateData[0]?.data[1]?.ratio * 100).toFixed(2)}+ {(queryHitRate[0]?.data![1]?.ratio * 100).toFixed(2)}</span><span className="text-xl">%</span></div>@@ -234,14 +153,24 @@ const QueryPerformanceReport: NextPageWithLayout = () => {</Accordion>)}+ <ReactMarkdown className="prose text-sm text-scale-1000" children={text} />++ <div className="mb-8">+ <Button type="default" onClick={() => setShowResetgPgStatStatements(true)}>+ Reset analysis+ </Button>+ </div>+<ConfirmModaldangervisible={showResetgPgStatStatements}- title="Reset query performance"- description={`This will reset the extensions.pg_stat_statements table that is used to calculate query performance.`}+ title="Reset query performance analysis"+ description={+ 'This will reset the `extensions.pg_stat_statements` table that is used to calculate query performance.'+ }buttonLabel="Clear table"buttonLoadingLabel="Deleting"- onSelectCancel={() => setShowResetgPgStatStatements(true)}+ onSelectCancel={() => setShowResetgPgStatStatements(false)}onSelectConfirm={async () => {try {await executeSql({@@ -256,176 +185,186 @@ const QueryPerformanceReport: NextPageWithLayout = () => {}}/>- <ReactMarkdown className="prose text-sm dark:dark-prose">- Unoptimized queries are a major cause of poor database performance. The techniques on this- page can help you identify and understand queries that take the most time and resources from- your database. You can read more about [query- performance](https://supabase.com/docs/guides/platform/performance#examining-query-performance)- in our docs.- </ReactMarkdown>-- <div className="w-full flex justify-end">- <Button type="default" onClick={() => setShowResetgPgStatStatements(true)}>- Reset analysis- </Button>- </div>-<div className="flex flex-col"><Tabs type="underlined" size="medium">- <Tabs.Panel key={1} id="1" label="Most time consuming" className="text-sm max-w-none">- <div className="thin-scrollbars max-w-full overflow-scroll">- <Table- head={- <>- <Table.th className="table-cell">Role</Table.th>- <Table.th className="table-cell">Time Consumed</Table.th>- <Table.th className="table-cell">Calls</Table.th>- <Table.th className="table-cell">Total Time</Table.th>- <Table.th className="table-cell">Query</Table.th>- </>- }- body={- isLoadedQueryMostTimeConsumingData ? (- QueryMostTimeConsumingData[0].data.map((item, i) => {- return (- <Table.tr key={i} hoverable className="relative">- <Table.td className="table-cell whitespace-nowrap w-36">- {item.rolname}- </Table.td>- <Table.td className="table-cell whitespace-nowrap">- {item.prop_total_time}- </Table.td>- <Table.td className="table-cell whitespace-nowrap">{item.calls}</Table.td>- <Table.td className="table-cell whitespace-nowrap">- {item.total_time.toFixed(2)}ms- </Table.td>- <Table.td className="relative table-cell whitespace-nowrap w-36">- <p className="w-96 block truncate font-mono">{item.query}</p>- <QueryActions sql={item.query} className="absolute inset-y-0 right-0" />- </Table.td>- </Table.tr>- )- })- ) : (- <></>- )- }- />+ <Tabs.Panel key={1} id="1" label="Most time consuming">+ <div className={panelClassNames}>+ <ReactMarkdown className={helperTextClassNames} children={TimeConsumingHelperText} />+ <div className="thin-scrollbars max-w-full overflow-scroll">+ <Table+ head={+ <>+ <Table.th className="table-cell">Role</Table.th>+ <Table.th className="table-cell">Time Consumed</Table.th>+ <Table.th className="table-cell">Calls</Table.th>+ <Table.th className="table-cell">Total Time</Table.th>+ <Table.th className="table-cell">Query</Table.th>+ </>+ }+ body={+ !isLoading && mostTimeConsuming ? (+ mostTimeConsuming[0].data!.map((item, i) => {+ return (+ <Table.tr key={i} hoverable className="relative">+ <Table.td className="table-cell whitespace-nowrap w-36">+ {item.rolname}+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap">+ {item.prop_total_time}+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap">+ {item.calls}+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap">+ {item.total_time.toFixed(2)}ms+ </Table.td>+ <Table.td className="relative table-cell whitespace-nowrap w-36">+ <p className="w-96 block truncate font-mono">{item.query}</p>+ <QueryActions+ sql={item.query}+ className="absolute inset-y-0 right-0"+ />+ </Table.td>+ </Table.tr>+ )+ })+ ) : (+ <></>+ )+ }+ />+ </div></div></Tabs.Panel>- <Tabs.Panel key={2} id="2" label="Most frequent" className="text-sm max-w-none">- <div className="thin-scrollbars max-w-full overflow-scroll">- <Table- head={- <>- {/* <Table.th className="table-cell">source</Table.th> */}- <Table.th className="table-cell">Role</Table.th>- <Table.th className="table-cell">Avg. Roles</Table.th>- <Table.th className="table-cell">Calls</Table.th>- <Table.th className="table-cell">Max Time</Table.th>- <Table.th className="table-cell">Mean Time</Table.th>- <Table.th className="table-cell">Min Time</Table.th>- <Table.th className="table-cell">Total Time</Table.th>- <Table.th className="table-cell">Query</Table.th>- </>- }- body={- isLoadedQueryMostFrequentlyInvokedData ? (- QueryMostFrequentlyInvokedData[0].data.map((item, i) => {- return (- <Table.tr key={i} hoverable className="relative">- <Table.td className="table-cell whitespace-nowrap w-28">- {item.rolname}- </Table.td>- <Table.td className="table-cell whitespace-nowrap">- {item.avg_rows}- </Table.td>- <Table.td className="table-cell whitespace-nowrap">{item.calls}</Table.td>- <Table.td className="table-cell whitespace-nowrap">- {item.max_time.toFixed(2)}ms- </Table.td>- <Table.td className="table-cell whitespace-nowrap truncate">- {item.mean_time.toFixed(2)}ms- </Table.td>- <Table.td className="table-cell whitespace-nowrap truncate">- {item.min_time.toFixed(2)}ms- </Table.td>- <Table.td className="table-cell whitespace-nowrap truncate">- {item.total_time.toFixed(2)}ms- </Table.td>- <Table.td className="relative table-cell whitespace-nowrap w-24">- <p className="w-48 block truncate font-mono ">{item.query}</p>- <QueryActions sql={item.query} className="absolute inset-y-0 right-0" />- </Table.td>- </Table.tr>- )- })- ) : (- <></>- )- }- />+ <Tabs.Panel key={2} id="2" label="Most frequent">+ <div className={panelClassNames}>+ <ReactMarkdown className={helperTextClassNames} children={MostFrequentHelperText} />+ <div className="thin-scrollbars max-w-full overflow-scroll">+ <Table+ head={+ <>+ {/* <Table.th className="table-cell">source</Table.th> */}+ <Table.th className="table-cell">Role</Table.th>+ <Table.th className="table-cell">Avg. Roles</Table.th>+ <Table.th className="table-cell">Calls</Table.th>+ <Table.th className="table-cell">Max Time</Table.th>+ <Table.th className="table-cell">Mean Time</Table.th>+ <Table.th className="table-cell">Min Time</Table.th>+ <Table.th className="table-cell">Total Time</Table.th>+ <Table.th className="table-cell">Query</Table.th>+ </>+ }+ body={+ !isLoading && mostFrequentlyInvoked ? (+ mostFrequentlyInvoked[0].data!.map((item, i) => {+ return (+ <Table.tr key={i} hoverable className="relative">+ <Table.td className="table-cell whitespace-nowrap w-28">+ {item.rolname}+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap">+ {item.avg_rows}+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap">+ {item.calls}+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap">+ {item.max_time.toFixed(2)}ms+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap truncate">+ {item.mean_time.toFixed(2)}ms+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap truncate">+ {item.min_time.toFixed(2)}ms+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap truncate">+ {item.total_time.toFixed(2)}ms+ </Table.td>+ <Table.td className="relative table-cell whitespace-nowrap w-24">+ <p className="w-48 block truncate font-mono ">{item.query}</p>+ <QueryActions+ sql={item.query}+ className="absolute inset-y-0 right-0"+ />+ </Table.td>+ </Table.tr>+ )+ })+ ) : (+ <></>+ )+ }+ />+ </div></div></Tabs.Panel>- <Tabs.Panel key={3} id="3" label="Slowest execution time" className="text-sm max-w-none">- <div className="thin-scrollbars max-w-full overflow-scroll">- <Table- head={- <>- <Table.th className="table-cell">Role</Table.th>- <Table.th className="table-cell">Avg Rows</Table.th>- <Table.th className="table-cell">Calls</Table.th>- <Table.th className="table-cell">Max Time</Table.th>- <Table.th className="table-cell">Mean Time</Table.th>- <Table.th className="table-cell">Min Time</Table.th>- <Table.th className="table-cell">Total Time</Table.th>- <Table.th className="table-cell">Query</Table.th>- </>- }- body={- isLoadedQuerySlowestExecutionTimeData ? (- QuerySlowestExecutionTimeData[0].data.map((item, i) => {- return (- <Table.tr key={i} hoverable className="relative">- <Table.td className="table-cell whitespace-nowrap w-24">- {item.rolname}- </Table.td>- <Table.td className="table-cell whitespace-nowrap">- {item.avg_rows}- </Table.td>- <Table.td className="table-cell whitespace-nowrap">{item.calls}</Table.td>- <Table.td className="table-cell whitespace-nowrap">- {item.max_time.toFixed(2)}ms- </Table.td>- <Table.td className="table-cell whitespace-nowrap truncate">- {item.mean_time.toFixed(2)}ms- </Table.td>- <Table.td className="table-cell whitespace-nowrap truncate">- {item.min_time.toFixed(2)}ms- </Table.td>- <Table.td className="table-cell whitespace-nowrap truncate">- {item.total_time.toFixed(2)}ms- </Table.td>- <Table.td className="relative table-cell whitespace-nowrap">- <p className="w-48 block truncate font-mono">{item.query}</p>- <QueryActions- sql={'item.query'}- className="absolute inset-y-0 right-0"- />- </Table.td>- </Table.tr>- )- })- ) : (- <></>- )- }+ <Tabs.Panel key={3} id="3" label="Slowest execution time">+ <div className={panelClassNames}>+ <ReactMarkdown+ className={helperTextClassNames}+ children={SlowestExecutionHelperText}/>+ <div className="thin-scrollbars max-w-full overflow-scroll">+ <Table+ head={+ <>+ <Table.th className="table-cell">Role</Table.th>+ <Table.th className="table-cell">Avg Rows</Table.th>+ <Table.th className="table-cell">Calls</Table.th>+ <Table.th className="table-cell">Max Time</Table.th>+ <Table.th className="table-cell">Mean Time</Table.th>+ <Table.th className="table-cell">Min Time</Table.th>+ <Table.th className="table-cell">Total Time</Table.th>+ <Table.th className="table-cell">Query</Table.th>+ </>+ }+ body={+ !isLoading && slowestExecutionTime ? (+ slowestExecutionTime[0].data!.map((item, i) => {+ return (+ <Table.tr key={i} hoverable className="relative">+ <Table.td className="table-cell whitespace-nowrap w-24">+ {item.rolname}+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap">+ {item.avg_rows}+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap">+ {item.calls}+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap">+ {item.max_time.toFixed(2)}ms+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap truncate">+ {item.mean_time.toFixed(2)}ms+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap truncate">+ {item.min_time.toFixed(2)}ms+ </Table.td>+ <Table.td className="table-cell whitespace-nowrap truncate">+ {item.total_time.toFixed(2)}ms+ </Table.td>+ <Table.td className="relative table-cell whitespace-nowrap">+ <p className="w-48 block truncate font-mono">{item.query}</p>+ <QueryActions+ sql={'item.query'}+ className="absolute inset-y-0 right-0"+ />+ </Table.td>+ </Table.tr>+ )+ })+ ) : (+ <></>+ )+ }+ />+ </div></div></Tabs.Panel></Tabs></div>- </>+ </Layout>)}diff --git a/studio/tailwind.config.js b/studio/tailwind.config.jsindex 21148b6013e..42d8f6c8553 100644--- a/studio/tailwind.config.js+++ b/studio/tailwind.config.js@@ -73,6 +73,125 @@ module.exports = ui({'code::after': {content: '""',},+ '--tw-prose-body': theme('colors.scale[1100]'),+ '--tw-prose-headings': theme('colors.scale[1200]'),+ '--tw-prose-lead': theme('colors.scale[1100]'),+ '--tw-prose-links': theme('colors.scale[1100]'),+ '--tw-prose-bold': theme('colors.scale[1100]'),+ '--tw-prose-counters': theme('colors.scale[1100]'),+ '--tw-prose-bullets': theme('colors.scale[900]'),+ '--tw-prose-hr': theme('colors.scale[500]'),+ '--tw-prose-quotes': theme('colors.scale[1100]'),+ '--tw-prose-quote-borders': theme('colors.scale[500]'),+ '--tw-prose-captions': theme('colors.scale[700]'),+ '--tw-prose-code': theme('colors.scale[1200]'),+ '--tw-prose-pre-code': theme('colors.scale[900]'),+ '--tw-prose-pre-bg': theme('colors.scale[400]'),+ '--tw-prose-th-borders': theme('colors.scale[500]'),+ '--tw-prose-td-borders': theme('colors.scale[200]'),+ '--tw-prose-invert-body': theme('colors.scale[200]'),+ '--tw-prose-invert-headings': theme('colors.white'),+ '--tw-prose-invert-lead': theme('colors.scale[500]'),+ '--tw-prose-invert-links': theme('colors.white'),+ '--tw-prose-invert-bold': theme('colors.white'),+ '--tw-prose-invert-counters': theme('colors.scale[400]'),+ '--tw-prose-invert-bullets': theme('colors.scale[600]'),+ '--tw-prose-invert-hr': theme('colors.scale[700]'),+ '--tw-prose-invert-quotes': theme('colors.scale[100]'),+ '--tw-prose-invert-quote-borders': theme('colors.scale[700]'),+ '--tw-prose-invert-captions': theme('colors.scale[400]'),+ // the following are typography overrides+ // examples can be seen here —> https://github.com/tailwindlabs/tailwindcss-typography/blob/master/src/styles.js+ // reset all header font weights+ 'h1, h2, h3, h4, h5': {+ fontWeight: '400',+ },+ h2: {+ fontWeight: '400',+ },+ p: {+ fontWeight: '400',+ },+ pre: {+ background: 'none',+ padding: 0,+ marginBottom: '32px',+ },+ ul: {+ listStyleType: 'none',+ paddingLeft: '1rem',+ },+ 'ul li': {+ position: 'relative',+ },+ 'ul li::before': {+ position: 'absolute',+ top: '0.75rem',+ left: '-1rem',+ height: '0.125rem',+ width: '0.5rem',+ borderRadius: '0.25rem',+ backgroundColor: 'var(--colors-scale7)',+ content: '""',+ },+ ol: {+ paddingLeft: '1rem',+ counterReset: 'item',+ listStyleType: 'none',+ },+ 'ol li': { display: 'block', position: 'relative', paddingLeft: '1rem' },+ 'ol li::before': {+ position: 'absolute',+ top: '0.25rem',+ left: '-1rem',+ height: '1.2rem',+ width: '1.2rem',+ borderRadius: '0.25rem',+ backgroundColor: 'var(--colors-scale3)',+ border: '1px solid var(--colors-scale5)',+ content: 'counter(item) " "',+ counterIncrement: 'item',+ fontSize: '12px',+ color: 'var(--colors-scale9)',+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'center',+ },++ 'p img': {+ border: '1px solid var(--colors-scale4)',+ borderRadius: '4px',+ overflow: 'hidden',+ },+ iframe: {+ border: '1px solid ' + theme('borderColor.DEFAULT'),+ borderRadius: theme('borderRadius.lg'),+ },+ td: {+ borderBottom: '1px solid ' + theme('colors.scale[400]'),+ },+ code: {+ fontWeight: '400',+ padding: '0.2rem 0.4rem',+ backgroundColor: theme('colors.scale[400]'),+ border: '1px solid ' + theme('colors.scale[500]'),+ borderRadius: theme('borderRadius.lg'),+ wordBreak: 'break-all',+ },+ a: {+ position: 'relative',+ transition: 'color 0.3s ease-in-out',+ paddingBottom: '2px',+ fontWeight: '400',+ color: 'var(--colors-scale12)',+ textDecorationLine: 'underline',+ textDecorationColor: 'var(--colors-brand7)',+ textDecorationThickness: '1px',+ textUnderlineOffset: '4px',+ },+ 'a:hover': {+ textDecorationColor: 'var(--colors-brand9)',+ },},},docs: {