Skip to content

feat: add preference for default View Data row limit#10170

Open
kundansable wants to merge 1 commit into
pgadmin-org:masterfrom
kundansable:fix-10104-viewdata-row-limit
Open

feat: add preference for default View Data row limit#10170
kundansable wants to merge 1 commit into
pgadmin-org:masterfrom
kundansable:fix-10104-viewdata-row-limit

Conversation

@kundansable

@kundansable kundansable commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #10104 — adds a preference to cap the row count fetched by the plain "View Data" action, so it's usable on large tables without always doing a full SELECT *.

Root Cause

Not a bug — a missing option. The Object Explorer's unqualified "View Data" shortcut always runs with no LIMIT, unlike "First 100 Rows" / "Last 100 Rows", which hardcode limit=100. On a large table, "View Data" always tries to fetch every row, and there was no way to change that default short of manually running a query with a LIMIT.

Fix

Add a new preference view_data_default_row_limit (integer, default 0 = unlimited, preserving current behavior) under the sqleditor module's Options category. In GridCommand.__init__, when cmd_type == VIEW_ALL_ROWS, read this preference and set self.limit to it if positive. The existing objectquery.sql template already renders a LIMIT clause only when limit > 0, so no template changes are needed. "First/Last 100 Rows" are untouched — they keep their own hardcoded limit.

Test Steps

  1. Open Preferences → SQL Editor / Options (or wherever the sqleditor preferences group renders) and confirm a new "Default View Data row limit" (or similarly labeled) integer preference exists, defaulting to 0.
  2. With the preference left at 0, right-click a table → View/Edit Data → View Data. Confirm behavior is unchanged (no LIMIT applied) from before this change.
  3. Set the preference to e.g. 50, then View Data on a table with more than 50 rows. Confirm exactly 50 rows load.
  4. Confirm "First 100 Rows" and "Last 100 Rows" still fetch exactly 100 rows regardless of this preference's value.
  5. Set the preference back to 0 and confirm "View Data" returns to unlimited.

Summary by CodeRabbit

  • New Features
    • Added a configurable row limit for the “View/Edit Data – All Rows” option.
    • A limit greater than zero now restricts the number of displayed rows.
    • The default setting of zero preserves the existing unlimited behavior.
    • The First 100 Rows and Last 100 Rows options remain unchanged.

The plain "View Data" shortcut always performs a SELECT * with no
LIMIT, which is effectively unusable on large tables since it always
tries to fetch every row. "First/Last 100 Rows" already avoid this by
hardcoding limit=100, but there was no way to make the default,
unqualified "View Data" action bounded.

Add a new preference, view_data_default_row_limit (integer, default 0
= unlimited, preserving current behavior), and apply it in
GridCommand.__init__ only for the VIEW_ALL_ROWS command type. The
existing objectquery.sql template already renders a LIMIT clause only
when limit > 0, so a positive preference value takes effect with no
template changes. First/Last 100 Rows are unaffected.

Fixes pgadmin-org#10104
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e5f1cbc5-0801-48f6-8a5b-95d6d507d5bb

📥 Commits

Reviewing files that changed from the base of the PR and between b15c745 and a2c251c.

📒 Files selected for processing (2)
  • web/pgadmin/tools/sqleditor/command.py
  • web/pgadmin/tools/sqleditor/utils/query_tool_preferences.py

Walkthrough

Adds a query tool preference for a default row limit and applies it to the “View/Edit Data - All Rows” command when configured with a positive value. First/Last 100 Rows behavior remains unchanged.

Changes

View Data Row Limit

Layer / File(s) Summary
Register and apply configurable row limit
web/pgadmin/tools/sqleditor/utils/query_tool_preferences.py, web/pgadmin/tools/sqleditor/command.py
Registers view_data_default_row_limit with a default of 0, then applies positive values to VIEW_ALL_ROWS; zero preserves the existing unlimited behavior and First/Last 100 Rows remain fixed at 100.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a default row-limit preference for View Data.
Linked Issues check ✅ Passed The changes implement #10104 by adding a configurable default LIMIT for View Data while leaving the 100-row shortcuts unchanged.
Out of Scope Changes check ✅ Passed All code changes are directly tied to the requested View Data row-limit preference and its SQL Editor handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to limit the rows shown by shortcut "View data"

1 participant