mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 09:56:00 +00:00
redis load keys optimalization
This commit is contained in:
@@ -229,9 +229,9 @@ module.exports = {
|
||||
},
|
||||
|
||||
loadKeys_meta: true,
|
||||
async loadKeys({ conid, database, root, filter }, req) {
|
||||
async loadKeys({ conid, database, root, filter, limit }, req) {
|
||||
testConnectionPermission(conid, req);
|
||||
return this.loadDataCore('loadKeys', { conid, database, root, filter });
|
||||
return this.loadDataCore('loadKeys', { conid, database, root, filter, limit });
|
||||
},
|
||||
|
||||
exportKeys_meta: true,
|
||||
|
||||
@@ -258,8 +258,8 @@ async function handleCollectionData({ msgid, options }) {
|
||||
return handleDriverDataCore(msgid, driver => driver.readCollection(dbhan, options), { logName: 'readCollection' });
|
||||
}
|
||||
|
||||
async function handleLoadKeys({ msgid, root, filter }) {
|
||||
return handleDriverDataCore(msgid, driver => driver.loadKeys(dbhan, root, filter), { logName: 'loadKeys' });
|
||||
async function handleLoadKeys({ msgid, root, filter, limit }) {
|
||||
return handleDriverDataCore(msgid, driver => driver.loadKeys(dbhan, root, filter, limit), { logName: 'loadKeys' });
|
||||
}
|
||||
|
||||
async function handleExportKeys({ msgid, options }) {
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
||||
import { apiCall } from '../utility/api';
|
||||
|
||||
const SHOW_INCREMENT = 500;
|
||||
// const SHOW_INCREMENT = 500;
|
||||
const SHOW_INCREMENT = 10;
|
||||
|
||||
import DbKeysTreeNode from './DbKeysTreeNode.svelte';
|
||||
|
||||
@@ -26,7 +27,7 @@
|
||||
// $: items = useDatabaseKeys({ conid, database, root, reloadToken });
|
||||
</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 />
|
||||
{:then items}
|
||||
{@const itemsSorted = _.sortBy(items || [], 'text')}
|
||||
|
||||
@@ -169,12 +169,14 @@ const driver = {
|
||||
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 keysFiltered = keys.filter((x) => filterName(filter, x));
|
||||
const res = this.extractKeysFromLevel(dbhan, root, keysFiltered);
|
||||
await this.enrichKeyInfo(dbhan, res);
|
||||
return res;
|
||||
const keysSorted = _.sortBy(keysFiltered, 'text');
|
||||
const res = this.extractKeysFromLevel(dbhan, root, keysSorted);
|
||||
const resLimited = limit ? res.slice(0, limit) : res;
|
||||
await this.enrichKeyInfo(dbhan, resLimited);
|
||||
return resLimited;
|
||||
},
|
||||
|
||||
async exportKeys(dbhan, options) {
|
||||
|
||||
Reference in New Issue
Block a user