Fwd: Re: [GENERAL] How to split a table? - Mailing list pgsql-sql

From Achilleas Mantzios
Subject Fwd: Re: [GENERAL] How to split a table?
Date
Msg-id 200610171408.44655.achill@matrix.gatewaynet.com
Whole thread Raw
List pgsql-sql
I forgot to mention that you would have to maintain a counter of each inserted
row and stop when you reach 60% of N (where N the cardinality of your source
table).

----------  Προωθημένο Μήνυμα  ----------

Subject: Re: [SQL] [GENERAL] How to split a table?
Date: Τρίτη 17 Οκτώβριος 2006 12:09
From: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: pgsql-sql@postgresql.org

Στις Τρίτη 17 Οκτώβριος 2006 11:34, ο/η Andreas Kretschmer έγραψε:
> Felix Zhang <felix.zhang.2005@gmail.com> schrieb:
> > Hi,
> >
> > I want to split a table to 2 small tables. The 1st one contains 60%
> > records which are randomly selected from the source table.
> > How to do it?
>
> Why do you want to do this?

In any case, you could write a program in perl and insert into the second
table rows from the first table, using a techique of generarting random
double precision numbers in a predetermined range (lets say 0 to 2^31-1), and
then converting this number to your "range" like this:
let your number be r.
let your table's cardinality be N.
then let R=(N*r/(2^31))+1

select a source row from your table like:

select * from srctable order by pk offset <R>,
and then insert this row to your desttable.

> Andreas

--
Achilleas Mantzios

-------------------------------------------------------

--
Achilleas Mantzios


pgsql-sql by date:

Previous
From: Jorge Godoy
Date:
Subject: Re: [GENERAL] How to split a table?
Next
From: Lewis Cunningham
Date:
Subject: Re: [GENERAL] Any documatation about porting from Oracle to PostgreSQL