Fixed query history slowness issue by storing query only for those having certain threshold max length. #6666

This commit is contained in:
Pravesh Sharma
2023-10-17 15:17:53 +05:30
committed by GitHub
parent 344c236d72
commit 5bb6e9133f
3 changed files with 18 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ import { MainToolBar } from './sections/MainToolBar';
import { Messages } from './sections/Messages';
import getApiInstance, {callFetch, parseApiError} from '../../../../../static/js/api_instance';
import url_for from 'sources/url_for';
import { PANELS, QUERY_TOOL_EVENTS, CONNECTION_STATUS } from './QueryToolConstants';
import { PANELS, QUERY_TOOL_EVENTS, CONNECTION_STATUS, MAX_QUERY_LENGTH } from './QueryToolConstants';
import { useInterval } from '../../../../../static/js/custom_hooks';
import { Box } from '@material-ui/core';
import { getDatabaseLabel, getTitle, setQueryToolDockerTitle } from '../sqleditor_title';
@@ -391,6 +391,13 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
window.addEventListener('unload', closeConn);
const pushHistory = (h)=>{
// Do not store query text if max lenght exceeds.
if(h?.query?.length > MAX_QUERY_LENGTH) {
h = {
...h,
query: gettext(`-- Query text not stored as it exceeds maximum length of ${MAX_QUERY_LENGTH}`)
};
}
api.post(
url_for('sqleditor.add_query_history', {
'trans_id': qtState.params.trans_id,

View File

@@ -101,3 +101,5 @@ export const PANELS = {
HISTORY: 'id-history',
GRAPH_VISUALISER: 'id-graph-visualiser',
};
export const MAX_QUERY_LENGTH = 1000000;

View File

@@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////
import { makeStyles } from '@material-ui/styles';
import React from 'react';
import { PANELS, QUERY_TOOL_EVENTS } from '../QueryToolConstants';
import { PANELS, QUERY_TOOL_EVENTS, MAX_QUERY_LENGTH } from '../QueryToolConstants';
import gettext from 'sources/gettext';
import pgAdmin from 'sources/pgadmin';
import _ from 'lodash';
@@ -418,6 +418,13 @@ export function QueryHistory() {
setLoaderText('');
const pushHistory = (h)=>{
// Do not store query text if max lenght exceeds.
if(h?.query?.length > MAX_QUERY_LENGTH) {
h = {
...h,
query: gettext(`-- Query text not stored as it exceeds maximum length of ${MAX_QUERY_LENGTH}`)
};
}
qhu.current.addEntry(h);
refresh({});
};