Re: Creating indexes in the background

Lists: pgsql-hackers
From: David Lee <davidomundo(at)gmail(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Creating indexes in the background
Date: 2012-10-27 23:20:46
Message-ID: D6D7E76B-C5F9-4EB4-963B-591928190865@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hey folks,

It seems like right now when you want to create an index concurrently, the index creation will get canceled if you cancel the statement (i.e. you must keep your statement open).

Is there a way to "launch" an index creation in the background so that the statement doesn't need to be kept open?

--David


From: David Johnston <polobo(at)yahoo(dot)com>
To: David Lee <davidomundo(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Creating indexes in the background
Date: 2012-10-28 14:48:24
Message-ID: 12358CC1-BEF6-47EF-A0DC-757AC99F6882@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Oct 27, 2012, at 19:20, David Lee <davidomundo(at)gmail(dot)com> wrote:

> Hey folks,
>
> It seems like right now when you want to create an index concurrently, the index creation will get canceled if you cancel the statement (i.e. you must keep your statement open).
>
> Is there a way to "launch" an index creation in the background so that the statement doesn't need to be kept open?
>
> --David
>

No there is not.

David J.


From: David Lee <davidomundo(at)gmail(dot)com>
To: David Johnston <polobo(at)yahoo(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Creating indexes in the background
Date: 2012-10-28 15:22:08
Message-ID: CAEsy2JEPPiau7jE7=Ng0FbvAAeqQxfkYetk=O3UZ7yyA35vf9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thanks. Is this something viable as a feature request?
On Oct 28, 2012 7:48 AM, "David Johnston" <polobo(at)yahoo(dot)com> wrote:

> On Oct 27, 2012, at 19:20, David Lee <davidomundo(at)gmail(dot)com> wrote:
>
> > Hey folks,
> >
> > It seems like right now when you want to create an index concurrently,
> the index creation will get canceled if you cancel the statement (i.e. you
> must keep your statement open).
> >
> > Is there a way to "launch" an index creation in the background so that
> the statement doesn't need to be kept open?
> >
> > --David
> >
>
> No there is not.
>
> David J.


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: David Lee <davidomundo(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Creating indexes in the background
Date: 2012-10-28 19:08:54
Message-ID: CAMkU=1wZEwYqnnNUbnYaiVRsx65Vq-k0uFn7ESQksoWEAQwO-w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Oct 27, 2012 at 4:20 PM, David Lee <davidomundo(at)gmail(dot)com> wrote:
> Hey folks,
>
> It seems like right now when you want to create an index concurrently, the index creation will get canceled if you cancel the statement (i.e. you must keep your statement open).
>
> Is there a way to "launch" an index creation in the background so that the statement doesn't need to be kept open?

Launch the session itself in the background.

For example, on linux:

psql -c 'create index concurrently ....' &

At some point, you will probably want to verify that the creation succeeded.

Cheers,

Jeff


From: Jaime Casanova <jaime(at)2ndquadrant(dot)com>
To: David Lee <davidomundo(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Creating indexes in the background
Date: 2012-10-28 20:19:18
Message-ID: CAJKUy5j47QarmYtaRTDNBv2GKa5gxJDGBg9EHxCZcYYHCfVt5w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Oct 27, 2012 at 6:20 PM, David Lee <davidomundo(at)gmail(dot)com> wrote:
> Hey folks,
>
> It seems like right now when you want to create an index concurrently, the index creation will get canceled if you cancel the statement (i.e. you must keep your statement open).
>
> Is there a way to "launch" an index creation in the background so that the statement doesn't need to be kept open?
>

do it in the command line:

psql -c "CREATE INDEX CONCURRENTLY aname ON atable(acolumn)" adb &

--
Jaime Casanova www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitaciĆ³n
Phone: +593 4 5107566 Cell: +593 987171157


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: David Lee <davidomundo(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Creating indexes in the background
Date: 2012-10-28 23:48:56
Message-ID: CAB7nPqRWuEoy6hFhN=JLR3R-OzeyRthUte7JnSitEZgz8_qUKA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Oct 28, 2012 at 8:20 AM, David Lee <davidomundo(at)gmail(dot)com> wrote:

> Hey folks,
>
> It seems like right now when you want to create an index concurrently, the
> index creation will get canceled if you cancel the statement (i.e. you must
> keep your statement open).
>
> Is there a way to "launch" an index creation in the background so that the
> statement doesn't need to be kept open?
>
If I understood your question, the answer is no, you need to maintain the
server session alive when doing a transaction on a PG server, cutting the
server connection automatically aborts the transaction it is running on
server side.
You can still use a batch processing for doing such operations like:
psql -c "create index concurrently foo on tab(a)" -p $port -h $host $dbname
&
But this needs to be done on the client application side that will maintain
alive a session on server.
--
Michael Paquier
http://michael.otacoo.com


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: David Lee <davidomundo(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Creating indexes in the background
Date: 2012-10-29 12:00:22
Message-ID: CA+TgmoYZiKNFFwoT65zKayP5yLVxGTJqrG+331CR6iH34VpDZA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Oct 27, 2012 at 7:20 PM, David Lee <davidomundo(at)gmail(dot)com> wrote:
> It seems like right now when you want to create an index concurrently, the index creation will get canceled if you cancel the statement (i.e. you must keep your statement open).
>
> Is there a way to "launch" an index creation in the background so that the statement doesn't need to be kept open?

Nope.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: David Lee <davidomundo(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Creating indexes in the background
Date: 2012-10-29 13:29:50
Message-ID: CA+U5nMKCrEaNn7_dxRAwUJm=5fNQ62KLRjPaA8ZK-oc5Z1yROQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 28 October 2012 01:20, David Lee <davidomundo(at)gmail(dot)com> wrote:

> It seems like right now when you want to create an index concurrently, the index creation will get canceled if you cancel the statement (i.e. you must keep your statement open).
>
> Is there a way to "launch" an index creation in the background so that the statement doesn't need to be kept open?

There is some work in 9.3 that will give low-level infrastructure
support to allow the concept of a "job/task scheduler" in Postgres,
which is the generic description of the facility you're looking for.
It is early days, but that will emerge sometime in 9.3 or beyond.

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Jim Nasby <jnasby(at)enova(dot)com>
To: David Lee <davidomundo(at)gmail(dot)com>
Cc: David Johnston <polobo(at)yahoo(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Creating indexes in the background
Date: 2012-10-29 20:50:25
Message-ID: 508EEC11.5080807@enova.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 10/28/12 10:22 AM, David Lee wrote:
> Thanks. Is this something viable as a feature request?

Possibly, but it's not terribly high on the list.

In the meantime, we've built a user-space index daemon at $WORK that generally solves this issue. We intend to release it at some point, but if you need it now we could provide you with code.
--
Jim "Decibel!" Nasby jnasby(at)enova(dot)com
Primary: 512-569-9461 Backup: 512-579-9024


From: Daniel Farina <daniel(at)heroku(dot)com>
To: David Lee <davidomundo(at)gmail(dot)com>
Cc: David Johnston <polobo(at)yahoo(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Creating indexes in the background
Date: 2012-10-31 23:37:41
Message-ID: CAAZKuFYP58fK8jBtARftgFW5P7N75+qrnrYQr6v7e5A-Z9LFOQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Oct 28, 2012 at 8:22 AM, David Lee <davidomundo(at)gmail(dot)com> wrote:
> Thanks. Is this something viable as a feature request?

Just to contribute a tiny amount of data: I also get this request from
users on a semi-regular basis. It's definitely below the pains of
pg_dump/restore or fork-and-reuse-of-connections of libpq in the space
of caveats that come to mind, but it's worth noting that regular
people do notice this is a gap (disconnected session support)
reasonably frequently. However, the workaround is fairly clear and
network connections are pretty reliable, and that blunts its severity.

it's also useful for other use cases besides CREATE INDEX, like
incremental data rewrites. I think there's some indirect overlap here
with the daemon facility under discussion that is active in another
thread.

--
fdr