redis load keys optimalization

This commit is contained in:
SPRINX0\prochazka
2025-01-22 08:49:58 +01:00
parent 0c35aefbe2
commit 4793bad92f
4 changed files with 13 additions and 10 deletions

View File

@@ -229,9 +229,9 @@ module.exports = {
}, },
loadKeys_meta: true, loadKeys_meta: true,
async loadKeys({ conid, database, root, filter }, req) { async loadKeys({ conid, database, root, filter, limit }, req) {
testConnectionPermission(conid, req); testConnectionPermission(conid, req);
return this.loadDataCore('loadKeys', { conid, database, root, filter }); return this.loadDataCore('loadKeys', { conid, database, root, filter, limit });
}, },
exportKeys_meta: true, exportKeys_meta: true,

View File

@@ -258,8 +258,8 @@ async function handleCollectionData({ msgid, options }) {
return handleDriverDataCore(msgid, driver => driver.readCollection(dbhan, options), { logName: 'readCollection' }); return handleDriverDataCore(msgid, driver => driver.readCollection(dbhan, options), { logName: 'readCollection' });
} }
async function handleLoadKeys({ msgid, root, filter }) { async function handleLoadKeys({ msgid, root, filter, limit }) {
return handleDriverDataCore(msgid, driver => driver.loadKeys(dbhan, root, filter), { logName: 'loadKeys' }); return handleDriverDataCore(msgid, driver => driver.loadKeys(dbhan, root, filter, limit), { logName: 'loadKeys' });
} }
async function handleExportKeys({ msgid, options }) { async function handleExportKeys({ msgid, options }) {

View File

@@ -5,7 +5,8 @@
import LoadingInfo from '../elements/LoadingInfo.svelte'; import LoadingInfo from '../elements/LoadingInfo.svelte';
import { apiCall } from '../utility/api'; import { apiCall } from '../utility/api';
const SHOW_INCREMENT = 500; // const SHOW_INCREMENT = 500;
const SHOW_INCREMENT = 10;
import DbKeysTreeNode from './DbKeysTreeNode.svelte'; import DbKeysTreeNode from './DbKeysTreeNode.svelte';
@@ -26,7 +27,7 @@
// $: items = useDatabaseKeys({ conid, database, root, reloadToken }); // $: items = useDatabaseKeys({ conid, database, root, reloadToken });
</script> </script>
{#await apiCall('database-connections/load-keys', { conid, database, root, filter, reloadToken, reloadToken2 })} {#await apiCall( 'database-connections/load-keys', { conid, database, root, filter, reloadToken, reloadToken2, limit: maxShowCount + 1 } )}
<LoadingInfo message="Loading key list" wrapper /> <LoadingInfo message="Loading key list" wrapper />
{:then items} {:then items}
{@const itemsSorted = _.sortBy(items || [], 'text')} {@const itemsSorted = _.sortBy(items || [], 'text')}

View File

@@ -169,12 +169,14 @@ const driver = {
return _.range(16).map((index) => ({ name: `db${index}`, extInfo: info[`db${index}`], sortOrder: index })); return _.range(16).map((index) => ({ name: `db${index}`, extInfo: info[`db${index}`], sortOrder: index }));
}, },
async loadKeys(dbhan, root = '', filter = null) { async loadKeys(dbhan, root = '', filter = null, limit = null) {
const keys = await this.getKeys(dbhan, root ? `${root}${dbhan.treeKeySeparator}*` : '*'); const keys = await this.getKeys(dbhan, root ? `${root}${dbhan.treeKeySeparator}*` : '*');
const keysFiltered = keys.filter((x) => filterName(filter, x)); const keysFiltered = keys.filter((x) => filterName(filter, x));
const res = this.extractKeysFromLevel(dbhan, root, keysFiltered); const keysSorted = _.sortBy(keysFiltered, 'text');
await this.enrichKeyInfo(dbhan, res); const res = this.extractKeysFromLevel(dbhan, root, keysSorted);
return res; const resLimited = limit ? res.slice(0, limit) : res;
await this.enrichKeyInfo(dbhan, resLimited);
return resLimited;
}, },
async exportKeys(dbhan, options) { async exportKeys(dbhan, options) {