Re: Correlation in pg_stats

From: Christian Hammers <ch(at)lathspell(dot)de>
To: classical_89 <luongnx512(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Correlation in pg_stats
Date: 2012-11-26 20:44:26
Message-ID: 20121126214426.72b9f86e@james.intern
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

Do you want to search for tables with many unordered rows?

SELECT
schemaname, tablename, correlation
FROM
pg_stats
WHERE
abs(correlation) < 0.2 and
schemaname not in ('pg_catalog', 'information_schema')
;

Or do you want to put the table in order?

BEGIN;
CREATE TABLE tbl_test_new (LIKE tbl_test INCLUDING ALL);
INSERT INTO tbl_test_new SELECT * FROM tbl_test ORDER BY id;
DROP TABLE tbl_test;
TABLE tbl_test_new RENAME TO tbl_test;
COMMIT;

If you really want to get a correlation of near 0 try

INSERT INTO tbl_test (name) SELECT random() FROM generate_series(1, 100);

bye,

-christian-

Am Mon, 26 Nov 2012 01:52:21 -0800 (PST)
schrieb classical_89 <luongnx512(at)gmail(dot)com>:

> Hi,First sorry for my bad English :D.I'm new in PostgreSQL and
> database .Now i'm researching about statistic correlation .I want to
> make a example with the table -assume that I have tbl_test table and
> two column - id & name - and do something to get correlation of a
> column is near 0 (zero).What step can i do ?
> Thanks for your support :)
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/Correlation-in-pg-stats-tp5733524.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Figueiredo Jr. 2012-11-26 20:44:49 Re: Npgsql
Previous Message Peter Kroon 2012-11-26 20:36:38 Re: Npgsql