Re: [HACKERS] pg_background contrib module proposal

Поиск
Список
Период
Сортировка
От Andrew Borodin
Тема Re: [HACKERS] pg_background contrib module proposal
Дата
Msg-id CAJEAwVEpKtTeR6oG=8=Lvbb6BVqoepMK5iH=9iuM6sEB-YCnFQ@mail.gmail.com
обсуждение исходный текст
Ответ на pg_background contrib module proposal  (amul sul <sulamul@gmail.com>)
Ответы Re: [HACKERS] pg_background contrib module proposal  (Craig Ringer <craig@2ndquadrant.com>)
Список pgsql-hackers
2016-12-21 4:55 GMT+05:00 David Fetter <david@fetter.org>:
> I see.
>
> I find the following a little easier to follow, and the sleeps still
> work even when very short.

Now I know a little more SQL :) Thank you.

I'm not sure every platform supports microsecond sleeps. But it will
work anyway. This test is deterministic.
Without sequence here is no race condition. So it is not sleepsort, it
is deterministic. Though I agree that it is good thing for test, I'd
still add some miliseconds to test case when main query for sure have
to wait end of other sleeping query.
.
>
> CREATE TABLE input AS
> SELECT x, row_number() OVER (ORDER BY x) n
> FROM
>     generate_series(0,.000005,0.000001) x
>     ORDER BY x DESC;
>
> CREATE TABLE output(place int,value float);
>
> CREATE TABLE handles AS
> SELECT pg_background_launch(
>     format($$
>         SELECT pg_sleep(%s);
>         INSERT INTO output VALUES (%s, %s)
>         $$,
>         x, n, x
>     )
> ) h
> FROM input;
>
> --wait until everyone finishes
> SELECT * FROM handles JOIN LATERAL pg_background_result(handles.h) AS (x TEXT) ON (true);
>
> --output results
> SELECT * FROM output ORDER BY place;

Best regrards, Andrey Borodin.



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

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: [HACKERS] bigint vs txid user confusion
Следующее
От: Petr Jelinek
Дата:
Сообщение: Re: [HACKERS] Logical decoding on standby