Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tsb5Z-0003Oy-8m for pgsql-general@arkaria.postgresql.org; Tue, 08 Jan 2013 15:27:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tsb5Y-00067h-63 for pgsql-general@arkaria.postgresql.org; Tue, 08 Jan 2013 15:27:40 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tsb5P-00060W-6h for pgsql-general@postgresql.org; Tue, 08 Jan 2013 15:27:31 +0000 Received: from mail-da0-f42.google.com ([209.85.210.42]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tsb5J-000833-7p for pgsql-general@postgresql.org; Tue, 08 Jan 2013 15:27:30 +0000 Received: by mail-da0-f42.google.com with SMTP id z17so241592dal.15 for ; Tue, 08 Jan 2013 07:27:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=TfS6fAgn2JSJCAdG1RYAN3/YjwsYqFeveEZXDRQOGiw=; b=JFHOCZqD/KZbBDqLHLHP/Rhzv3XXM2DM/oBiDSktMYX1ui+t6hCmQXalcURK5Fxfwj Lo7+UNPDB4c1mqeNtlxQjo4nxKKU0dkAkmyGBwzRFsh0nvA5JjoNZtQbywDuWi7bzMdH 8+rIkkyy2797ZhIu3CNIFn6RXDVa7Ejmf/2hMjA/2thTEGbNzfYu5hTU3ed4Zh2ndCnp I9Px8TtpBKLo8hzDF1VsBxewRTVOBkme0gjE1LRgigrHcasZF8E4zyc/uHH7HUdFkInv 16e90mxEpnBXsRIdkUu+92WLWz6iViZpxHb9MmqkQdkuJILOAb2mvNix5AdTNmvJBnO/ WLMw== X-Received: by 10.68.217.4 with SMTP id ou4mr197494567pbc.88.1357658843874; Tue, 08 Jan 2013 07:27:23 -0800 (PST) Received: from [192.168.0.2] (c-24-17-164-54.hsd1.wa.comcast.net. [24.17.164.54]) by mx.google.com with ESMTPS id x2sm40930639paw.8.2013.01.08.07.27.22 (version=SSLv3 cipher=OTHER); Tue, 08 Jan 2013 07:27:23 -0800 (PST) Message-ID: <50EC3AD9.1030902@gmail.com> Date: Tue, 08 Jan 2013 07:27:21 -0800 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Stefan Keller CC: pgsql-general List , PostGIS Users Discussion Subject: Re: Query with LIMIT but as random result set? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On 01/08/2013 07:20 AM, Stefan Keller wrote: > 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). SELECT ST_AsText(way) geom, name AS label FROM osm_point ORDER BY random() LIMIT 10; > > Yours, Stefan > > -- Adrian Klaver adrian.klaver@gmail.com -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general