Skip to content

Table data sorting is incorrect in Adaptive Ordering mode on a bigserial type id column #40539

@Lem26

Description

@Lem26

Description

The data order is invalid in Adaptive Ordering mode:
It does not follow numerical descending order.
It also does not follow valid string lexicographical descending order.
The largest id value is incorrectly placed at the end of consecutive rows with identical prefixes, breaking the sort logic entirely.

DBeaver Version

Community Edition 26.0

Operating System

macOS Sequoia 15.2

Database and driver

PostgreSQL 17

Steps to reproduce

  1. Ensure Adaptive Ordering mode is enabled (this is the default behavior for sorting table data in DBeaver).
  2. Connect to PostgreSQL database, and open the Data tab for a table with a bigserial primary key column.
  3. Click the downward arrow (↓) next to the id column header to trigger a descending sort.
  4. Observe the order of the returned data rows.
  5. Data should be sorted strictly in numerical descending order (largest to smallest) by the id column, even when using in-memory Adaptive Ordering.
    For example, for the 3 rows in the screenshot (rows 4-6), the correct descending order should be:
    Row 4: 2030565120120958979 (largest value)
    Row 5: 2030565120120958978
    Row 6: 2030565120120958977 (smallest value)

Sample data , DDL and screenshot are shown as follows:

local_message.sql

Image

Additional context

  1. This issue is consistently reproduced on Windows 11, PostgreSQL 13, and DBeaver CE 25.3 and older versions.
  2. We have confirmed the id column is a native bigserial numerical type, not a string/varchar type.
    This issue only occurs in Adaptive Ordering mode. If we disable Adaptive Ordering and force a server-side ORDER BY id DESC, the sorting works correctly.
  3. We suspect DBeaver's in-memory sorting logic is incorrectly treating the 64-bit bigserial integer as a string or failing to handle its full numerical precision, leading to the broken order.

Thanks for your time and help to look into this issue!

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions