mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-08-18 17:04:53 -05:00
feat: add preference for default View Data row limit (#10170)
The unqualified "View Data" action always ran with no LIMIT, unlike "First/Last 100 Rows" which hardcode limit=100 — unusable on large tables with no way to cap it. Add view_data_default_row_limit preference (int, default 0 = unlimited) under sqleditor Options. GridCommand.__init__ applies it as self.limit when cmd_type == VIEW_ALL_ROWS and the value is positive; objectquery.sql already renders LIMIT only when > 0, so no template changes needed. First/Last 100 Rows untouched. Closes #10104
This commit is contained in:
@@ -363,6 +363,14 @@ class GridCommand(BaseCommand, SQLFilter, FetchedRowTracker):
|
||||
|
||||
if self.cmd_type in (VIEW_FIRST_100_ROWS, VIEW_LAST_100_ROWS):
|
||||
self.limit = 100
|
||||
elif self.cmd_type == VIEW_ALL_ROWS:
|
||||
# Apply the user-configurable default row limit (if any) for the
|
||||
# "All Rows" option. A value of 0 (the default) means no limit,
|
||||
# preserving the existing behaviour of fetching all rows.
|
||||
default_row_limit = Preferences.module('sqleditor').preference(
|
||||
'view_data_default_row_limit').get()
|
||||
if default_row_limit and default_row_limit > 0:
|
||||
self.limit = default_row_limit
|
||||
|
||||
self.thread_native_id = None
|
||||
self.server_cursor = kwargs['server_cursor'] if\
|
||||
|
||||
@@ -120,6 +120,21 @@ def register_query_tool_preferences(self):
|
||||
"First/Last 100 Rows options, data is always sorted.")
|
||||
)
|
||||
|
||||
self.view_data_default_row_limit = self.preference.register(
|
||||
'Options', 'view_data_default_row_limit',
|
||||
gettext("Default row limit for View Data"), 'integer', 0,
|
||||
min_val=0,
|
||||
category_label=PREF_LABEL_OPTIONS,
|
||||
help_str=gettext(
|
||||
"Specify the maximum number of rows to fetch when using the "
|
||||
"View/Edit Data - All Rows option. This appends a LIMIT clause "
|
||||
"to the generated query, which can significantly improve "
|
||||
"performance on very large tables. Set to 0 (the default) to "
|
||||
"fetch all rows with no limit (the existing behavior). This "
|
||||
"does not affect the First/Last 100 Rows options."
|
||||
)
|
||||
)
|
||||
|
||||
self.show_prompt_save_data_changes = self.preference.register(
|
||||
'Options', 'prompt_save_data_changes',
|
||||
gettext("Prompt to save unsaved data changes?"), 'boolean', True,
|
||||
|
||||
Reference in New Issue
Block a user