Skip site navigation (1) Skip section navigation (2)

Sort is actually PlanState?

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Sort is actually PlanState?
Date: 2010-11-02 00:55:47
Message-ID: AANLkTimEhJ=ZR_HT1XciS8kGEsw17ViCGhZwGoEPtFfb@mail.gmail.com (view raw)
I wonder why SortState is a ScanState. As far as I know ScanState
means the node may need projection and/or qualification, or it scans
some relation, but Sort actually doesn't do such things. I also tried
to modify SortState as PlanState as in the attached patch and
regression test passed. Do I misunderstand ScanState?

Regards,

-- 
Hitoshi Harada
Attachment: sort-plan.20101102.patch
Description: application/octet-stream (4.6 KB)
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Sort is actually PlanState?
Date: 2010-11-02 01:06:22
Message-ID: 9733.1288659982@sss.pgh.pa.us (view raw)
Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> writes:
> I wonder why SortState is a ScanState. As far as I know ScanState
> means the node may need projection and/or qualification, or it scans
> some relation, but Sort actually doesn't do such things.

No, not really.  Per the comment for ScanState:

 *        ScanState extends PlanState for node types that represent
 *        scans of an underlying relation.  It can also be used for nodes
 *        that scan the output of an underlying plan node --- in that case,
 *        only ScanTupleSlot is actually useful, and it refers to the tuple
 *        retrieved from the subplan.

It might be that we don't actually need ScanTupleSlot right now in the
implementation of Sort, but I don't see a good reason to remove the
field.  We might just have to put it back later.

BTW, Sort is not the only node type like this --- I see at least
Material that's not projection-capable but has a ScanState.

			regards, tom lane

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Sort is actually PlanState?
Date: 2010-11-02 02:49:13
Message-ID: AANLkTinzOtb2yuNbKs+Yt--G95WnB_MRWcaaR65m_vQM@mail.gmail.com (view raw)
2010/11/2 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> writes:
>> I wonder why SortState is a ScanState. As far as I know ScanState
>> means the node may need projection and/or qualification, or it scans
>> some relation, but Sort actually doesn't do such things.
>
> No, not really.  Per the comment for ScanState:
>
>  *        ScanState extends PlanState for node types that represent
>  *        scans of an underlying relation.  It can also be used for nodes
>  *        that scan the output of an underlying plan node --- in that case,
>  *        only ScanTupleSlot is actually useful, and it refers to the tuple
>  *        retrieved from the subplan.
>
> It might be that we don't actually need ScanTupleSlot right now in the
> implementation of Sort, but I don't see a good reason to remove the
> field.  We might just have to put it back later.

It might reduce a few cycle used in initializing and cleaning of
ScanTupleSlot, but I basically agree it's not good reason to do it.

> BTW, Sort is not the only node type like this --- I see at least
> Material that's not projection-capable but has a ScanState.

Yes, during designing DtScan which is coming in the writeable CTEs I
came up with the question.

Regards,


-- 
Hitoshi Harada


Privacy Policy | About PostgreSQL
Copyright © 1996-2013 The PostgreSQL Global Development Group