Re: Indexes on partitioned tables and foreign partitions

2018-05-14 Thread Amit Langote
On 2018/05/15 2:29, Alvaro Herrera wrote: > On 2018-May-10, Amit Langote wrote: > >> How about we error out even *before* calling DefineIndex for the 1st time? >> I see that ProcessUtilitySlow() gets a list of all partitions when >> locking them for index creation before calling DefineIndex. May

Re: Indexes on partitioned tables and foreign partitions

2018-05-14 Thread Alvaro Herrera
On 2018-May-10, Amit Langote wrote: > How about we error out even *before* calling DefineIndex for the 1st time? > I see that ProcessUtilitySlow() gets a list of all partitions when > locking them for index creation before calling DefineIndex. Maybe, just > go through the list and error out if o

Re: Indexes on partitioned tables and foreign partitions

2018-05-13 Thread Robert Haas
On Fri, May 11, 2018 at 8:52 AM, Simon Riggs wrote: > I think its reasonable to expect you interpret my words sensibly, > rather than in some more dramatic form where I seem to break rules > with every phrase. Sure, I agree. I try to interpret the words of everyone here sensibly and without unne

Re: Indexes on partitioned tables and foreign partitions

2018-05-11 Thread Simon Riggs
On 9 May 2018 at 17:33, Robert Haas wrote: > On Wed, May 9, 2018 at 11:20 AM, Simon Riggs wrote: >> On 9 May 2018 at 16:15, Robert Haas wrote: >>> On Wed, May 9, 2018 at 11:14 AM, Simon Riggs wrote: On 9 May 2018 at 16:10, Tom Lane wrote: > Robert Haas writes: >> On Wed, May 9, 2

Re: Indexes on partitioned tables and foreign partitions

2018-05-10 Thread Robert Haas
On Wed, May 9, 2018 at 10:20 PM, Amit Langote wrote: > But it seems I've misinterpreted what he was saying. He doesn't seem to > be saying anything about how or whether we enforce the unique constraint > on foreign tables. Only that if someone creates a constraint index on the > partitioned tabl

Re: Indexes on partitioned tables and foreign partitions

2018-05-10 Thread Ashutosh Bapat
On Thu, May 10, 2018 at 8:30 AM, Amit Langote wrote: > > How about we error out even *before* calling DefineIndex for the 1st time? > I see that ProcessUtilitySlow() gets a list of all partitions when > locking them for index creation before calling DefineIndex. Maybe, just > go through the list

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Amit Langote
On 2018/05/10 10:02, Michael Paquier wrote: > Something > that I find confusing on HEAD though is that DefineIndex calls itself > around line 1006 and cascades through each children but there is no > context about the error. > > For example if I have this partition layer: > CREATE TABLE measuremen

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Amit Langote
On 2018/05/10 10:37, Michael Paquier wrote: > On Thu, May 10, 2018 at 10:15:05AM +0900, Amit Langote wrote: >> While I agree with this, let me point out that we do allow inherited check >> constraints on foreign tables that are not actually enforced locally. >> >> create table p (a int) partition b

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Michael Paquier
On Thu, May 10, 2018 at 10:15:05AM +0900, Amit Langote wrote: > While I agree with this, let me point out that we do allow inherited check > constraints on foreign tables that are not actually enforced locally. > > create table p (a int) partition by range (a); > create table p1 partition of p for

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Amit Langote
On 2018/05/09 23:57, Robert Haas wrote: > For right now, I think the options are (1) throw an ERROR if we > encounter a foreign table or (2) silently skip the foreign table. I > think (2) is defensible for non-UNIQUE indexes, because the index is > just a performance optimization. Along with othe

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Michael Paquier
On Wed, May 09, 2018 at 11:10:43AM -0400, Tom Lane wrote: > Agreed about unique indexes. I suggest that we throw an error for both > cases, because (1) having unique and non-unique indexes behave differently > for this purpose seems pretty weird; (2) throwing an error now preserves > our options t

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Arseny Sher
Simon Riggs writes: > Indexes on foreign tables cause an ERROR, so yes, we already just > don't create them. > > You're suggesting silently skipping the ERROR. I can't see a reason for that. Truly, I was inaccurate. I mean that index propagation is a nice feature, and making it available for mi

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Robert Haas
On Wed, May 9, 2018 at 11:12 AM, Simon Riggs wrote: > If we can assume an index exists on a foreign table, why can we not > just assume a unique index exists?? Why the difference? We can't assume either of those things, and I didn't say that we should. -- Robert Haas EnterpriseDB: http://www.en

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Robert Haas
On Wed, May 9, 2018 at 11:20 AM, Simon Riggs wrote: > On 9 May 2018 at 16:15, Robert Haas wrote: >> On Wed, May 9, 2018 at 11:14 AM, Simon Riggs wrote: >>> On 9 May 2018 at 16:10, Tom Lane wrote: Robert Haas writes: > On Wed, May 9, 2018 at 9:08 AM, Simon Riggs wrote: >> Shouldn'

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Simon Riggs
On 9 May 2018 at 16:15, Robert Haas wrote: > On Wed, May 9, 2018 at 11:14 AM, Simon Riggs wrote: >> On 9 May 2018 at 16:10, Tom Lane wrote: >>> Robert Haas writes: On Wed, May 9, 2018 at 9:08 AM, Simon Riggs wrote: > Shouldn't the fix be to allow creation of indexes on foreign tables?

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Robert Haas
On Wed, May 9, 2018 at 11:14 AM, Simon Riggs wrote: > On 9 May 2018 at 16:10, Tom Lane wrote: >> Robert Haas writes: >>> On Wed, May 9, 2018 at 9:08 AM, Simon Riggs wrote: Shouldn't the fix be to allow creation of indexes on foreign tables? (Maybe they would be virtual or foreign inde

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Simon Riggs
On 9 May 2018 at 16:10, Tom Lane wrote: > Robert Haas writes: >> On Wed, May 9, 2018 at 9:08 AM, Simon Riggs wrote: >>> Shouldn't the fix be to allow creation of indexes on foreign tables? >>> (Maybe they would be virtual or foreign indexes??) > >> It might be useful to invent the concept of a f

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Simon Riggs
On 9 May 2018 at 15:57, Robert Haas wrote: > For right now, I think the options are (1) throw an ERROR if we > encounter a foreign table or (2) silently skip the foreign table. I > think (2) is defensible for non-UNIQUE indexes, because the index is > just a performance optimization. However, fo

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Tom Lane
Robert Haas writes: > On Wed, May 9, 2018 at 9:08 AM, Simon Riggs wrote: >> Shouldn't the fix be to allow creation of indexes on foreign tables? >> (Maybe they would be virtual or foreign indexes??) > It might be useful to invent the concept of a foreign index, but not > for v11 a month after fe

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Robert Haas
On Wed, May 9, 2018 at 9:08 AM, Simon Riggs wrote: > How much sense is it to have a partitioned table with a mix of local > and foreign tables? Fair question, but we put some effort into making it work, so I think it should keep working. > Shouldn't the fix be to allow creation of indexes on for

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Simon Riggs
On 9 May 2018 at 15:26, Arseny Sher wrote: > > Simon Riggs writes: > >> How much sense is it to have a partitioned table with a mix of local >> and foreign tables? > > Well, as much sense as fdw-based sharding has, for instance. It is > arguable, but it exists. > >> Shouldn't the fix be to allow

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Arseny Sher
Simon Riggs writes: > How much sense is it to have a partitioned table with a mix of local > and foreign tables? Well, as much sense as fdw-based sharding has, for instance. It is arguable, but it exists. > Shouldn't the fix be to allow creation of indexes on foreign tables? > (Maybe they woul

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Simon Riggs
On 9 May 2018 at 12:50, Arseny Sher wrote: > Hi, > > 8b08f7d4 added propagation of indexes on partitioned tables to > partitions, which is very cool. However, index creation also recurses > down to foreign tables. I doubt this is intentional, as such indexes are > forbidden as not making much sens

Re: Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Ashutosh Bapat
On Wed, May 9, 2018 at 5:20 PM, Arseny Sher wrote: > Hi, > > 8b08f7d4 added propagation of indexes on partitioned tables to > partitions, which is very cool. However, index creation also recurses > down to foreign tables. I doubt this is intentional, as such indexes are > forbidden as not making m

Indexes on partitioned tables and foreign partitions

2018-05-09 Thread Arseny Sher
Hi, 8b08f7d4 added propagation of indexes on partitioned tables to partitions, which is very cool. However, index creation also recurses down to foreign tables. I doubt this is intentional, as such indexes are forbidden as not making much sense; attempt to create index on partitioned table with fo