mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed query history slowness issue by storing query only for those having certain threshold max length. #6666
This commit is contained in:
@@ -18,7 +18,7 @@ import { MainToolBar } from './sections/MainToolBar';
|
|||||||
import { Messages } from './sections/Messages';
|
import { Messages } from './sections/Messages';
|
||||||
import getApiInstance, {callFetch, parseApiError} from '../../../../../static/js/api_instance';
|
import getApiInstance, {callFetch, parseApiError} from '../../../../../static/js/api_instance';
|
||||||
import url_for from 'sources/url_for';
|
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 { useInterval } from '../../../../../static/js/custom_hooks';
|
||||||
import { Box } from '@material-ui/core';
|
import { Box } from '@material-ui/core';
|
||||||
import { getDatabaseLabel, getTitle, setQueryToolDockerTitle } from '../sqleditor_title';
|
import { getDatabaseLabel, getTitle, setQueryToolDockerTitle } from '../sqleditor_title';
|
||||||
@@ -391,6 +391,13 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
|
|||||||
window.addEventListener('unload', closeConn);
|
window.addEventListener('unload', closeConn);
|
||||||
|
|
||||||
const pushHistory = (h)=>{
|
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(
|
api.post(
|
||||||
url_for('sqleditor.add_query_history', {
|
url_for('sqleditor.add_query_history', {
|
||||||
'trans_id': qtState.params.trans_id,
|
'trans_id': qtState.params.trans_id,
|
||||||
|
|||||||
@@ -101,3 +101,5 @@ export const PANELS = {
|
|||||||
HISTORY: 'id-history',
|
HISTORY: 'id-history',
|
||||||
GRAPH_VISUALISER: 'id-graph-visualiser',
|
GRAPH_VISUALISER: 'id-graph-visualiser',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const MAX_QUERY_LENGTH = 1000000;
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
import { makeStyles } from '@material-ui/styles';
|
import { makeStyles } from '@material-ui/styles';
|
||||||
import React from 'react';
|
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 gettext from 'sources/gettext';
|
||||||
import pgAdmin from 'sources/pgadmin';
|
import pgAdmin from 'sources/pgadmin';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
@@ -418,6 +418,13 @@ export function QueryHistory() {
|
|||||||
setLoaderText('');
|
setLoaderText('');
|
||||||
|
|
||||||
const pushHistory = (h)=>{
|
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);
|
qhu.current.addEntry(h);
|
||||||
refresh({});
|
refresh({});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user