Re: [HACKERS] advanced partition matching algorithm forpartition-wise join

Поиск
Список
Период
Сортировка
От Etsuro Fujita
Тема Re: [HACKERS] advanced partition matching algorithm forpartition-wise join
Дата
Msg-id CAPmGK14dxedHjaFpm5N-Keonk_Qk85y4e_0v6TMr2Ys4ob6K4Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] advanced partition matching algorithm forpartition-wise join  (Ashutosh Bapat <ashutosh.bapat@2ndquadrant.com>)
Список pgsql-hackers
On Mon, Apr 6, 2020 at 8:43 PM Ashutosh Bapat
<ashutosh.bapat@2ndquadrant.com> wrote:
> On Fri, 3 Apr 2020 at 20:45, Etsuro Fujita <etsuro.fujita@gmail.com> wrote:
> But it will be good to have following addition I suggested in my patches to make sure nparts is set to 0 for an
unpartitionedrelation as per the comment on nparts in RelOptInfo.
 
> @@ -1653,6 +1663,8 @@ build_joinrel_partition_info(RelOptInfo *joinrel, RelOptInfo *outer_rel,
>                                 jointype, restrictlist))
>     {
>         Assert(!IS_PARTITIONED_REL(joinrel));
> +       /* Join is not partitioned. */
> +       joinrel->nparts = 0;
>         return;
>     }

I didn't modified that function as proposed, because I thought that 1)
there would be no need to do so, and that 2) it would be better to set
joinrel->nparts only when we set joinrel->part_schema, for
consistency.

>> >> 3) I think the for nparts comment is somewhat misleading:
>> >>
>> >>    int nparts;  /* number of partitions; 0 = not partitioned;
>> >>                  * -1 = not yet set */
>> >>
>> >> which says that nparts=0 means not partitioned. But then there are
>> >> conditions like this:
>> >>
>> >>      /* Nothing to do, if the join relation is not partitioned. */
>> >>      if (joinrel->part_scheme == NULL || joinrel->nparts == 0)
>> >>          return;
>> >>
>> >> which (ignoring the obsolete comment) seems to say we can have nparts==0
>> >> even for partitioned tables, no?
>>
>> Yeah, I think I was a bit hasty.  I fixed this.

> For a non-join relation, nparts = 0 and nparts = -1 both have the same meaning. Although we never set nparts = 0 for
anon-join relation?
 

I don't think so.  Consider this:

create table prt (a int, b int) partition by range (a);
create table prt_p1 partition of prt for values from (0) to (250);
create table prt_p2 partition of prt for values from (250) to (500);
drop table prt_p1;
drop table prt_p2;
select count(*) from prt;

For this query, we would have nparts=0 for the partitioned table prt.

Thanks!  Sorry for the delay.

Best regards,
Etsuro Fujita



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

Предыдущее
От: yuzuko
Дата:
Сообщение: Re: Autovacuum on partitioned table (autoanalyze)
Следующее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Race condition in SyncRepGetSyncStandbysPriority