Skip to content

Commit

Permalink
#16397 ability to disable metadata objects comment reading (#18781)
Browse files Browse the repository at this point in the history
* #16397 ability to disable metadata objects comment reading for performance increasing added

* #16397 change setting description

* #16397 move connection setting to the separate connection page; remove constraints comments reading

Co-authored-by: Serge Rider <serge@jkiss.org>
  • Loading branch information
LonwoLonwo and serge-rider committed Jan 18, 2023
1 parent a687624 commit 5463637
Show file tree
Hide file tree
Showing 17 changed files with 297 additions and 59 deletions.
7 changes: 7 additions & 0 deletions plugins/org.jkiss.dbeaver.ext.vertica.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ Bundle-SymbolicName: org.jkiss.dbeaver.ext.vertica.ui;singleton:=true
Bundle-Version: 1.0.89.qualifier
Bundle-Release-Date: 20230123
Require-Bundle: org.jkiss.dbeaver.model,
org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.jface.text,
org.eclipse.ui.views,
org.eclipse.ui.workbench,
org.jkiss.dbeaver.model,
org.jkiss.dbeaver.ui,
org.jkiss.dbeaver.ui.editors.base,
org.jkiss.dbeaver.ui.editors.connection,
org.jkiss.dbeaver.ext.vertica,
org.jkiss.dbeaver.ext.generic,
org.jkiss.dbeaver.ext.generic.ui
Expand Down
1 change: 1 addition & 0 deletions plugins/org.jkiss.dbeaver.ext.vertica.ui/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ output.. = target/classes/
bin.includes = .,\
META-INF/,\
OSGI-INF/,\
icons/,\
plugin.xml
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions plugins/org.jkiss.dbeaver.ext.vertica.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
dataSource="vertica"
targetID="org.jkiss.dbeaver.ext.ui.newConnectionWizard"
label="%dialog.connection.header"
class="org.jkiss.dbeaver.ext.generic.views.GenericConnectionPage"
class="org.jkiss.dbeaver.ext.vertica.ui.views.VerticaConnectionPage"
icon="platform:/plugin/org.jkiss.dbeaver.ext.vertica/icons/icons/vertica_icon.png">
</view>
<view
class="org.jkiss.dbeaver.ext.generic.views.GenericConnectionPage"
class="org.jkiss.dbeaver.ext.vertica.ui.views.VerticaConnectionPage"
icon="platform:/plugin/org.jkiss.dbeaver.ext.vertica/icons/icons/vertica_icon.png"
id="org.jkiss.dbeaver.ext.vertica.dataSourceEditorView"
dataSource="vertica"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2023 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.vertica.ui.internal;

import org.eclipse.osgi.util.NLS;

public class VerticaUIMessages extends NLS {

static final String BUNDLE_NAME = "org.jkiss.dbeaver.ext.vertica.ui.internal.VerticaUIMessages"; //$NON-NLS-1$

static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, VerticaUIMessages.class);
}

private VerticaUIMessages() {
// prevents construction
}

public static String connection_page_group_performance;
public static String connection_page_group_checkbox_disable_comments;
public static String connection_page_group_checkbox_disable_comments_tip;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
connection_page_group_performance = Performance
connection_page_group_checkbox_disable_comments = Disable objects comments reading
connection_page_group_checkbox_disable_comments_tip = Disable objects (tables/sequences/projections, etc.) comments reading.\nReading this type of information can dramatically reduce data loading speed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
connection_page_group_performance = \u041F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C
connection_page_group_checkbox_disable_comments = \u041E\u0442\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u0447\u0442\u0435\u043D\u0438\u0435 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u0432 \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u0432
connection_page_group_checkbox_disable_comments_tip = \u041E\u0442\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u0447\u0442\u0435\u043D\u0438\u0435 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u0432 \u043E\u0431\u044A\u0435\u043A\u0442\u043E\u0432 (\u0442\u0430\u0431\u043B\u0438\u0446/\u043F\u043E\u0441\u043B\u0435\u0434\u043E\u0432\u0430\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u0435\u0439/\u043F\u0440\u043E\u0435\u043A\u0446\u0438\u0439, etc.).\n\u0427\u0442\u0435\u043D\u0438\u0435 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u0432 \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0445 \u0442\u0430\u0431\u043B\u0438\u0446 \u043C\u043E\u0436\u0435\u0442 \u0437\u043D\u0430\u0447\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0441\u043D\u0438\u0437\u0438\u0442\u044C \u0441\u043A\u043E\u0440\u043E\u0441\u0442\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0438 \u0434\u0430\u043D\u043D\u044B\u0445.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2023 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.vertica.ui.views;

import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.swt.graphics.Image;
import org.jkiss.dbeaver.ext.generic.views.GenericConnectionPage;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.connection.DriverPropertiesDialogPage;

public class VerticaConnectionPage extends GenericConnectionPage {

private final Image logoImage;

public VerticaConnectionPage() {
logoImage = createImage("icons/vertica_logo.png"); //$NON-NLS-1$
}

@Override
public void dispose() {
super.dispose();
UIUtils.dispose(logoImage);
}

@Override
public Image getImage() {
return logoImage;
}

@Override
public IDialogPage[] getDialogPages(boolean extrasOnly, boolean forceCreate) {
return new IDialogPage[] {
new VerticaConnectionPageAdvanced(),
new DriverPropertiesDialogPage(this)
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2023 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.vertica.ui.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.jkiss.dbeaver.ext.vertica.VerticaConstants;
import org.jkiss.dbeaver.ext.vertica.ui.internal.VerticaUIMessages;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.connection.ConnectionPageAbstract;
import org.jkiss.utils.CommonUtils;

public class VerticaConnectionPageAdvanced extends ConnectionPageAbstract {

private Button disableCommentsReading;

public VerticaConnectionPageAdvanced() {
setTitle("Vertica");
}

@Override
public void createControl(Composite parent) {
Composite group = new Composite(parent, SWT.NONE);
group.setLayout(new GridLayout(1, false));
group.setLayoutData(new GridData(GridData.FILL_BOTH));

{
Group advancedSettings = new Group(group, SWT.NONE);
advancedSettings.setText(VerticaUIMessages.connection_page_group_performance);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 4;
advancedSettings.setLayoutData(gridData);
advancedSettings.setLayout(new GridLayout(1, false));

disableCommentsReading = UIUtils.createCheckbox(
advancedSettings,
VerticaUIMessages.connection_page_group_checkbox_disable_comments,
VerticaUIMessages.connection_page_group_checkbox_disable_comments_tip,
false,
1);
}

setControl(group);
loadSettings();

}

@Override
public void loadSettings() {
DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration();
disableCommentsReading.setSelection(CommonUtils.toBoolean(
connectionInfo.getProviderProperty(VerticaConstants.PROP_DISABLE_COMMENTS_READING)));
super.loadSettings();
}

@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
DBPConnectionConfiguration connectionInfo = dataSource.getConnectionConfiguration();
if (disableCommentsReading != null) {
connectionInfo.setProviderProperty(
VerticaConstants.PROP_DISABLE_COMMENTS_READING,
String.valueOf(disableCommentsReading.getSelection()));
}
super.saveSettings(dataSource);
}

@Override
public boolean isComplete() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public class VerticaConstants {
public static String TYPE_FLEX_TABLE = "FLEX TABLE";
public static String TYPE_SYSTEM_TABLE = "SYSTEM TABLE";

public static final String PROP_DISABLE_COMMENTS_READING = "disable-comments-reading@";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vertica_password_will_expire_warn_name = \u041F\u0430\u0440\u043E\u043B\u044C \u0441\u043A\u043E\u0440\u043E \u0438\u0441\u0442\u0435\u0447\u0451\u0442
vertica_password_will_expire_warn_description = \u0414\u0435\u0442\u0430\u043B\u0438: {0}\n\n\u0427\u0442\u043E\u0431\u044B \u0438\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0442\u0435\u043A\u0443\u0449\u0438\u0439 \u043F\u0430\u0440\u043E\u043B\u044C, \u043E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u043D\u043E\u0435 \u043C\u0435\u043D\u044E \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043A \u0432\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u044B \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u043D\u0430\u0432\u0438\u0433\u0430\u0442\u043E\u0440\u0430, \u0432\u044B\u0431\u0435\u0440\u0438\u0442\u0435 "\u0411\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u043E\u0441\u0442\u044C" -> "\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u043F\u0430\u0440\u043E\u043B\u044C \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044F".\n\u0415\u0441\u043B\u0438 \u0432\u044B \u043D\u0435 \u043C\u043E\u0436\u0435\u0442\u0435 \u043F\u043E\u043C\u0435\u043D\u044F\u0442\u044C \u043F\u0430\u0440\u043E\u043B\u044C, \u0442\u043E \u043E\u0431\u0440\u0430\u0442\u0438\u0442\u0435\u0441\u044C \u043A \u0432\u0430\u0448\u0435\u043C\u0443 DBA.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ext.generic.model.GenericDataSource;
import org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel;
import org.jkiss.dbeaver.ext.vertica.VerticaConstants;
import org.jkiss.dbeaver.ext.vertica.internal.VerticaMessages;
import org.jkiss.dbeaver.model.DBPDataKind;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
Expand Down Expand Up @@ -191,6 +192,10 @@ public <T> T getAdapter(Class<T> adapter) {
public boolean isChildCommentColumnAvailable(@NotNull DBRProgressMonitor monitor) {
// child_object is very helpful column in v_catalog.comments table, but it's not childObjectColumnAvailable in Vertica versions < 9.3 and in some other cases
if (childObjectColumnAvailable == null) {
if (avoidCommentsReading()) {
childObjectColumnAvailable = false;
return false;
}
try {
try (JDBCSession session = DBUtils.openMetaSession(monitor, this, "Check child comment column existence")) {
try (final JDBCPreparedStatement dbStat = session.prepareStatement(
Expand All @@ -207,6 +212,15 @@ public boolean isChildCommentColumnAvailable(@NotNull DBRProgressMonitor monitor
return childObjectColumnAvailable;
}

/**
*
* v_catalog.comments dramatically reduces data loading speed. User can disable metadata objects comments reading to avoid it.
*/
boolean avoidCommentsReading() {
return CommonUtils.toBoolean(
getContainer().getConnectionConfiguration().getProviderProperty(VerticaConstants.PROP_DISABLE_COMMENTS_READING));
}


class NodeCache extends JDBCObjectCache<VerticaDataSource, VerticaNode> {
@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,11 @@ public boolean supportsSequences(@NotNull GenericDataSource dataSource) {

@Override
public JDBCStatement prepareSequencesLoadStatement(@NotNull JDBCSession session, @NotNull GenericStructContainer container) throws SQLException {
boolean avoidCommentsReading = ((VerticaDataSource) container.getDataSource()).avoidCommentsReading();
JDBCPreparedStatement dbStat = session.prepareStatement(
"SELECT s.*, c.comment FROM v_catalog.sequences s\n" +
"LEFT JOIN v_catalog.comments c\n" +
"ON s.sequence_id = c.object_id\n" +
"SELECT s.*" + (avoidCommentsReading ? "" : ", c.comment") + " FROM v_catalog.sequences s\n" +
(avoidCommentsReading ? "" : "LEFT JOIN v_catalog.comments c\n" +
"ON s.sequence_id = c.object_id\n") +
"WHERE sequence_schema=? ORDER BY sequence_name");
dbStat.setString(1, container.getSchema().getName());
return dbStat;
Expand Down Expand Up @@ -259,18 +260,16 @@ public DBCQueryTransformer createQueryTransformer(@NotNull DBCQueryTransformType
public JDBCStatement prepareUniqueConstraintsLoadStatement(@NotNull JDBCSession session, @NotNull GenericStructContainer owner, @Nullable GenericTableBase forParent) throws SQLException, DBException {
JDBCPreparedStatement dbStat;
dbStat = session.prepareStatement("SELECT col.constraint_name as PK_NAME, col.table_name as TABLE_NAME, col.column_name as COLUMN_NAME, " +
"c.ordinal_position as KEY_SEQ, col.constraint_type, tc.predicate, col.is_enabled \n" +
"FROM v_catalog.constraint_columns col\n" +
"LEFT JOIN v_catalog.columns c ON\n" +
"c.table_id = col.table_id\n" +
//"LEFT JOIN v_catalog.comments com ON com.object_id = col.constraint_id"
// v_catalog.comments dramatically reduces data loading speed. Maybe we can use another table or use lazy cache for constraints too
"JOIN v_catalog.table_constraints tc ON\n" +
"tc.constraint_id = col.constraint_id \n" +
"AND col.column_name = c.column_name \n" +
"WHERE col.constraint_type IN ('u','p','c')\n" +
"AND col.table_schema = ?" + (forParent != null ? " AND col.table_name = ?" : "") +
" ORDER BY col.table_id, KEY_SEQ, PK_NAME");
"c.ordinal_position as KEY_SEQ, col.constraint_type, tc.predicate, col.is_enabled\n" +
"FROM v_catalog.constraint_columns col\n" +
"LEFT JOIN v_catalog.columns c ON\n" +
"c.table_id = col.table_id\n" +
"JOIN v_catalog.table_constraints tc ON\n" +
"tc.constraint_id = col.constraint_id \n" +
"AND col.column_name = c.column_name \n" +
"WHERE col.constraint_type IN ('u','p','c')\n" +
"AND col.table_schema = ?" + (forParent != null ? " AND col.table_name = ?" : "") +
" ORDER BY col.table_id, KEY_SEQ, PK_NAME");
if (forParent != null) {
dbStat.setString(1, forParent.getSchema().getName());
dbStat.setString(2, forParent.getName());
Expand All @@ -297,14 +296,12 @@ public DBSEntityConstraintType getUniqueConstraintType(JDBCResultSet dbResult) t
@Override
public GenericUniqueKey createConstraintImpl(GenericTableBase table, String constraintName, DBSEntityConstraintType constraintType, JDBCResultSet dbResult, boolean persisted) {
String checkExpression = "";
String comment = null;
boolean isEnabled = false;
if (dbResult != null) {
checkExpression = JDBCUtils.safeGetString(dbResult, "predicate");
comment = JDBCUtils.safeGetString(dbResult, "comment");
isEnabled = JDBCUtils.safeGetBoolean(dbResult, "is_enabled");
}
return new VerticaConstraint(table, constraintName, comment, constraintType, persisted, CommonUtils.notEmpty(checkExpression).trim(), isEnabled);
return new VerticaConstraint(table, constraintName, null, constraintType, persisted, CommonUtils.notEmpty(checkExpression).trim(), isEnabled);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,11 @@ public class ProjectionCache extends JDBCStructLookupCache<VerticaSchema, Vertic
@NotNull
@Override
public JDBCStatement prepareLookupStatement(@NotNull JDBCSession session, @NotNull VerticaSchema schema, @Nullable VerticaProjection object, @Nullable String objectName) throws SQLException {
boolean avoidCommentsReading = ((VerticaDataSource) schema.getDataSource()).avoidCommentsReading();
final JDBCPreparedStatement dbStat = session.prepareStatement(
"SELECT p.*,c.comment FROM v_catalog.projections p\n" +
"LEFT OUTER JOIN v_catalog.comments c ON c.object_type = 'PROJECTION' AND c.object_schema = p.projection_schema AND c.object_name = p.projection_name\n" +
"SELECT p.*" + (avoidCommentsReading ? "" : ",c.comment") + " FROM v_catalog.projections p\n" +
(avoidCommentsReading ? "" : "LEFT OUTER JOIN v_catalog.comments c ON c.object_type = 'PROJECTION'\n" +
"AND c.object_schema = p.projection_schema AND c.object_name = p.projection_name\n") +
"WHERE p.projection_schema=?" +
(object == null && objectName == null ? "" : " AND projection_name=?")
);
Expand All @@ -246,8 +248,9 @@ protected VerticaProjection fetchObject(@NotNull JDBCSession session, @NotNull V
protected JDBCStatement prepareChildrenStatement(@NotNull JDBCSession session, @NotNull VerticaSchema owner, @Nullable VerticaProjection forTable)
throws SQLException
{
String sql = ("SELECT pc.*,c.comment FROM v_catalog.projection_columns pc\n" +
"LEFT OUTER JOIN v_catalog.comments c ON c.object_id = pc.column_id\n" +
boolean avoidCommentsReading = ((VerticaDataSource) owner.getDataSource()).avoidCommentsReading();
String sql = ("SELECT pc.*" + (avoidCommentsReading ? "" : ",c.comment") + " FROM v_catalog.projection_columns pc\n" +
(avoidCommentsReading ? "" : "LEFT OUTER JOIN v_catalog.comments c ON c.object_id = pc.column_id\n") +
"WHERE pc.projection_id=?\n" +
"ORDER BY pc.column_position");

Expand Down

0 comments on commit 5463637

Please sign in to comment.