pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: Antoine <asolomon15@nyc.rr.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: looking for large dataset
Date: Mon, 5 May 2003 10:25:57 -0600 (MDT)
Message-ID: <Pine.LNX.4.33.0305051023270.2776-200000@css120.ihs.com> (raw)
In-Reply-To: <1051941161.4247.12.camel@logic>

On 3 May 2003, Antoine wrote:

> I was woundering where could I find a nice large dataset.  Perhaps 50
> thousand records or more 

I've attached a PHP script called mktestdb that reads in the dictionary at 
/usr/share/dict/words,  and inserts a user defined number of rows into a 
user defined number of columns.

It's ugly and simple.  Just pipe the output to a text file or psql and off 
you go.

usage:

mktestdb tablename [rows [cols]]

default of 1 column and 1000 rows.

It would be easy enough to rewrite this in something more portable if 
someone wanted to.

Attachments:

mktestdb (text/plain, 1.1K) download #!/usr/local/bin/php -q <?php set_time_limit(1200); if ($argc<2||$argc>4) die("Usage:\n\n mktestdb tablename [rows [cols]]\n\n"); $tablename = $argv[1]; if ($argc>=3) $rows = $argv[2]; else $rows = 1000; if ($argc==4) $cols = $argv[3]; else $cols = 1; function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } srand(make_seed()); $filename = "/usr/share/dict/words"; $fp = fopen($filename,"r"); $body = fread($fp,filesize($filename)); $lines = explode("\n",$body); $count = count($lines); $query = "create table $tablename (\n"; for ($i=0;$i<$cols;$i++){ $query.="\tcol_".$i; $query.=" text"; if ($i<$cols-1) $query.=", \n"; else $query.="\n"; } $query.=");"; print $query."\n\n"; print "-- Data for $tablename\n\n"; print "COPY $tablename ("; for ($i=0;$i<$cols;$i++){ print "col_".$i; if ($i<$cols-1) print ","; } print ") FROM STDIN;\n"; for ($i=0;$i<$rows;$i++){ for ($j=0;$j<$cols;$j++){ $k=rand(0,$count-1); print $lines[$k]; if ($j<$cols-1) print "\t"; } print "\n"; } print '\.'; print "\n"; ?>

view thread (4+ messages)

Message-ID: <Pine.LNX.4.33.0305051023270.2776-200000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0305051023270.2776-200000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0305051023270.2776-200000@css120.ihs.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: scott.marlowe@ihs.com, asolomon15@nyc.rr.com
  Subject: Re: looking for large dataset
  In-Reply-To: <Pine.LNX.4.33.0305051023270.2776-200000@css120.ihs.com>
  References: <1051941161.4247.12.camel@logic> <Pine.LNX.4.33.0305051023270.2776-200000@css120.ihs.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