Re: [HACKERS] pg_background contrib module proposal
От | David Fetter |
---|---|
Тема | Re: [HACKERS] pg_background contrib module proposal |
Дата | |
Msg-id | 20161220235536.GC22538@fetter.org обсуждение исходный текст |
Ответ на | Re: [HACKERS] pg_background contrib module proposal (Andrew Borodin <borodin@octonica.com>) |
Список | pgsql-hackers |
On Mon, Dec 19, 2016 at 09:30:32PM +0500, Andrew Borodin wrote: > 2016-12-19 4:21 GMT+05:00 David Fetter <david@fetter.org>: > > Couldn't it sleep in increments smaller than a second? Like maybe > > milliseconds? Also, it's probably cleaner (or at least more > > comprehensible) to write something using format() and dollar quoting > > than the line with the double 's. > > Right. Here's version which waits for half a second. I do not see how > to path doubles via dollar sign, pg_background_launch() gets a string > as a parameter, it's not EXCEUTE USING. I see. I find the following a little easier to follow, and the sleeps still work even when very short. Best, David. 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; -- David Fetter <david(at)fetter(dot)org> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate
В списке pgsql-hackers по дате отправления: