Re: How to create a specific table

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: How to create a specific table
Дата
Msg-id 14364B5E-04E0-458C-884F-BCEEB905A516@gmail.com
обсуждение исходный текст
Ответ на How to create a specific table  (Pierre Hsieh <pierre.hsieh@gmail.com>)
Список pgsql-general
> On 22 Jan 2015, at 15:54, Pierre Hsieh <pierre.hsieh@gmail.com> wrote:
> rule:
> 1. just one column which type is integer in table
> 2. this columns only has 1 and 2 for 50 times as following
>
> 1
> 2
> 1
> 2
> 1
> 2
> 1
> 2
> .....

create table test as select b from generate_series(1,50) s1(a), generate_series(1,2) s2(b);

But since tables are unordered sets, you'll need something to order your data by when querying, so I'd use this:

create table test as select a, b from generate_series(1,50) s1(a), generate_series(1,2) s2(b);
select b from test order by a,b;


I'm kind of curious what kind of problem you're trying to solve. First you ask how to calculate the standard deviation
ofblocks of 50 records and now this. Are you sure those blocks are ALWAYS 50 records large? Never, say 49 or 51 because
somerecords either weren't stored at all or were stored in the wrong block? If that occurs, you're dealing with an
increasingskew in your statistics. Perhaps the right thing to ask yourself is what groups those 50 records together,
whatdo they have in common? 

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.



В списке pgsql-general по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: Retrieving the role in a logical replication plugin
Следующее
От: Tim Smith
Дата:
Сообщение: In need of some JSONB examples ?