pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Chambers <gwchamb@gmail.com>
To: Justin Graf <justin@magwerks.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Inserting Multiple Random Rows
Date: Wed, 28 Apr 2010 15:19:40 -0400
Message-ID: <w2q302670f21004281219ue31d0e61xe3a76d0e2a49b5be@mail.gmail.com> (raw)
In-Reply-To: <4BD86B65.3070006@magwerks.com>
References: <q2x302670f21004280922ic25b4f91k968effc6926a6243@mail.gmail.com>
	<4BD86B65.3070006@magwerks.com>

Justin,

Thanks for the reply!

> you need to generate a series of random numbers then select each record
> one at a time out of cities table .  You will have to write a plsql
> function to do this As any join will cause the result to be ordered.

After modifying my search terms at Google, I've discovered that I'm
not alone in this endeavor.  There are a couple of informative
articles, the most beneficial of which is written by depesz at
http://www.depesz.com/index.php/2007/09/16/my-thoughts-on-getting-random-row/
and the one that referred me to it at
http://blog.rhodiumtoad.org.uk/2009/03/08/selecting-random-rows-from-a-table/

> Here is example of pl-sql procedure that inserts records randomly into a
> table from a another table.

I could have been done with this in pretty short order if I had just
continued with writing a quick PL/pgSQL function to do it.  It's all
Quassnoi's fault that I abandoned my original plan and tried to solve
the problem with a query.  After all, I need to learn to think in sets
and get out of the procedural mindset, but I still haven't heard the
click! :)

Thanks for the suggestion in your follow-up e-mail.  I'll post the
solution upon discovering it.

-- Gary Chambers

/* Nothing fancy and nothing Microsoft! */



view thread (7+ messages)  latest in thread

Message-ID: <w2q302670f21004281219ue31d0e61xe3a76d0e2a49b5be@mail.gmail.com>
Permalink:  ../w2q302670f21004281219ue31d0e61xe3a76d0e2a49b5be@mail.gmail.com/
Also on:    postgresql.org/message-id/w2q302670f21004281219ue31d0e61xe3a76d0e2a49b5be@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gwchamb@gmail.com, justin@magwerks.com
  Subject: Re: Inserting Multiple Random Rows
  In-Reply-To: <w2q302670f21004281219ue31d0e61xe3a76d0e2a49b5be@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox