Default ordering option - Mailing list pgsql-general

From Cyril Champier
Subject Default ordering option
Date
Msg-id CAJaA8VcZCkBZeEMt45g-YR7c6ScHbB3PNURt6Z7AWZuuvX5umA@mail.gmail.com
Whole thread Raw
Responses Re: Default ordering option  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: Default ordering option  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-general
Hi,

In this documentation, it is said:
If sorting is not chosen, the rows will be returned in an unspecified order. The actual order in that case will depend on the scan and join plan types and the order on disk, but it must not be relied on.

I would like to know if there is any way to change that to have a "real" random behaviour.

My use case:
At Doctolib, we do a lot of automatic tests.
Sometimes, people forgot to order their queries. Most of the time, there is no real problem on production. Let say, we display a user list without order.
When a developer writes a test for this feature, he will create 2 users A and B, then assert that they are displayed "[A, B]".
99% of the time the test will be ok, but sometimes, the displayed list will be "[B,A]", and the test will fail.

One solution could be to ensure random order with an even distribution, so that such failing test would be detected quicker.

Is that possible? Maybe with a plugin?

Thanks,
Cyril



pgsql-general by date:

Previous
From: Perumal Raj
Date:
Subject: Re: pg_upgrade : 9.X to 11.X issue CentoOS 7.6
Next
From: Perumal Raj
Date:
Subject: Re: pg_upgrade : 9.X to 11.X issue CentoOS 7.6