Re: tablesample with partitioned tables

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: David Fetter <david(at)fetter(dot)org>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tablesample with partitioned tables
Date: 2017-02-23 04:53:50
Message-ID: f7317f7e-6620-d0ae-ab6f-0ce1c285e14d@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017/02/23 0:54, David Fetter wrote:
> On Wed, Feb 22, 2017 at 04:51:46PM +0900, Amit Langote wrote:
>> Attached patch fixes an oversight that tablesample cannot be used with
>> partitioned tables:
>>
>> create table p (a int) partition by list (a);
>> select * from p tablesample bernoulli (50);
>> ERROR: TABLESAMPLE clause can only be applied to tables and materialized
>> views
>
> Thanks!
>
> Should the error message change somehow to reflect that partitioned
> tables are included? Is complete transparency of partitioned tables
> the goal, and reasonable in this context?

We avoid mentioning partitioned tables separately during most of the
errors caused by relkind checks. I mentioned recently [1] that in most of
these sites such as this one, a table's being partitioned is not significant.

> Also, is there a good reason apart from tuits not to expand
> TABLESAMPLE to the rest of our SQL-visible relation structures? I'm
> guessing this could have something to do with the volatility they
> might have, whether in views that call volatile functions or in
> foreign tables that might not make the right guarantees...

I wouldn't be able to say much about that, but I found an email from the
original discussion that occurred around development of this feature that
posed the same question. There might be some answers there.

[1]
https://www.postgresql.org/message-id/854ad246-4dfa-5c68-19ad-867b6800f313%40lab.ntt.co.jp
[2] https://www.postgresql.org/message-id/5526D369.1070905%40gmx.net

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Corey Huinker 2017-02-23 05:11:22 Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
Previous Message Amit Langote 2017-02-23 04:14:38 Re: Range Partitioning behaviour - query