Query with LIMIT but as random result set?

From: Stefan Keller <sfkeller(at)gmail(dot)com>
To: pgsql-general List <pgsql-general(at)postgresql(dot)org>, PostGIS Users Discussion <postgis-users(at)postgis(dot)refractions(dot)net>
Subject: Query with LIMIT but as random result set?
Date: 2013-01-08 15:20:58
Message-ID: CAFcOn29dNnQVAbqvTKoy3iwUK7sZOosvG0gRzPHW5DxA0Z9W-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

I have a query like this

SELECT ST_AsText(way) geom, name AS label
FROM osm_point
LIMIT 10;

When I repeatedly do this, the result set will be always the same.
I have observed this only empirically and I know that the ordering of
the result set is undefined without ORDER BY.
There are two indexes involved, one geospatial for way and one for name.

My question is: Does someone have an idea on how to randomize the
result set on every consecutive query?
And as an option the (limited) resultset should be spatially
distributed (not clustered).

Yours, Stefan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2013-01-08 15:27:21 Re: Query with LIMIT but as random result set?
Previous Message Wolfgang Keller 2013-01-08 15:20:07 Re: Database Design: Maintain Audit Trail of Changes