Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ export const QUERY_PERFORMANCE_PRESET_MAP = {

export const QUERY_PERFORMANCE_REPORTS = {
[QUERY_PERFORMANCE_REPORT_TYPES.MOST_TIME_CONSUMING]: [
{ id: 'query', name: 'Query', description: undefined, minWidth: 600 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: undefined },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: 60 },
{ id: 'query', name: 'Query', description: undefined, minWidth: 500 },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: 100 },
{ id: 'total_time', name: 'Total time', description: 'latency', minWidth: 150 },
{ id: 'prop_total_time', name: 'Time consumed', description: undefined, minWidth: 110 },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: 80 },
{ id: 'prop_total_time', name: 'Time consumed', description: undefined, minWidth: 150 },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: 150 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: 120 },
],
[QUERY_PERFORMANCE_REPORT_TYPES.MOST_FREQUENT]: [
{ id: 'query', name: 'Query', description: undefined, minWidth: 600 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: undefined },
{ id: 'avg_rows', name: 'Avg. Rows', description: undefined, minWidth: undefined },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: undefined },
{ id: 'max_time', name: 'Max time', description: undefined, minWidth: undefined },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: undefined },
{ id: 'min_time', name: 'Min time', description: undefined, minWidth: undefined },
{ id: 'total_time', name: 'Total time', description: 'latency', minWidth: 180 },
{ id: 'query', name: 'Query', description: undefined, minWidth: 500 },
{ id: 'avg_rows', name: 'Avg. Rows', description: undefined, minWidth: 100 },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: 100 },
{ id: 'total_time', name: 'Total time', description: 'latency', minWidth: 150 },
{ id: 'max_time', name: 'Max time', description: undefined, minWidth: 150 },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: 150 },
{ id: 'min_time', name: 'Min time', description: undefined, minWidth: 150 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: 120 },
],
[QUERY_PERFORMANCE_REPORT_TYPES.SLOWEST_EXECUTION]: [
{ id: 'query', name: 'Query', description: undefined, minWidth: 600 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: undefined },
{ id: 'avg_rows', name: 'Avg. Rows', description: undefined, minWidth: undefined },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: undefined },
{ id: 'max_time', name: 'Max time', description: undefined, minWidth: undefined },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: undefined },
{ id: 'min_time', name: 'Min time', description: undefined, minWidth: undefined },
{ id: 'total_time', name: 'Total time', description: 'latency', minWidth: 180 },
{ id: 'query', name: 'Query', description: undefined, minWidth: 500 },
{ id: 'avg_rows', name: 'Avg. Rows', description: undefined, minWidth: 100 },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: 100 },
{ id: 'total_time', name: 'Total time', description: 'latency', minWidth: 150 },
{ id: 'max_time', name: 'Max time', description: undefined, minWidth: 150 },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: 150 },
{ id: 'min_time', name: 'Min time', description: undefined, minWidth: 150 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: 120 },
],
} as const
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { useDatabaseRolesQuery } from 'data/database-roles/database-roles-query'
import { DbQueryHook } from 'hooks/analytics/useDbQuery'
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { Button } from 'ui'
import { Button, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import { Input } from 'ui-patterns/DataInputs/Input'
import { useQueryPerformanceSort } from './hooks/useQueryPerformanceSort'

export const QueryPerformanceFilterBar = ({
queryPerformanceQuery,
Expand All @@ -22,6 +23,7 @@ export const QueryPerformanceFilterBar = ({
}) => {
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
const { sort, clearSort } = useQueryPerformanceSort()
const [showBottomSection] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.QUERY_PERF_SHOW_BOTTOM_SECTION,
true
Expand Down Expand Up @@ -63,7 +65,7 @@ export const QueryPerformanceFilterBar = ({
}, [searchValue])

return (
<div className="px-6 py-2 bg-surface-200 border-t -mt-px flex justify-between items-center">
<div className="px-6 py-2 bg-surface-200 border-t -mt-px flex justify-between items-center overflow-x-auto w-full">
<div className="flex items-center gap-x-4">
<div className="flex items-center gap-x-2">
<Input
Expand Down Expand Up @@ -98,10 +100,24 @@ export const QueryPerformanceFilterBar = ({
onSaveFilters={onFilterRolesChange}
className="w-56"
/>

{sort && (
<div className="text-xs border rounded-md px-1.5 md:px-2.5 py-1 h-[26px] flex items-center gap-x-2">
<p className="md:inline-flex gap-x-1 hidden truncate">
Sort: {sort.column} <span className="text-foreground-lighter">{sort.order}</span>
</p>
<Tooltip>
<TooltipTrigger onClick={clearSort}>
<X size={14} className="text-foreground-light hover:text-foreground" />
</TooltipTrigger>
<TooltipContent side="bottom">Clear sort</TooltipContent>
</Tooltip>
</div>
)}
</div>
</div>

<div className="flex gap-2 items-center">
<div className="flex gap-2 items-center pl-2">
{!showBottomSection && onResetReportClick && (
<Button type="default" onClick={() => onResetReportClick()}>
Reset report
Expand Down
Loading
Loading