| From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
|---|---|
| To: | Richard Guo <guofenglinux(at)gmail(dot)com> |
| Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Use LIMIT instead of Unique for DISTINCT when all distinct pathkeys are redundant |
| Date: | 2022-10-13 10:43:23 |
| Message-ID: | CAApHDvp11sTNa--eexB1VF+BU31O9_SNwHkOPa8cxWog6pDcTA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, 13 Oct 2022 at 21:17, Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
>
> On Thu, Oct 13, 2022 at 2:48 PM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>> To stop the planner from adding that final sort, I opted to hack the
>> LimitPath's pathkeys to say that it's already sorted by the
>> PlannerInfo's sort_pathkeys. That feels slightly icky, but it does
>> seem a little wasteful to initialise a sort node on every execution of
>> the plan to sort a single tuple.
>
>
> I don't get how this plan comes out. It seems not correct because Limit
> node above an unsorted path would give us an unpredictable row.
Actually, you're right. That manual setting of the pathkeys is an
unneeded remanent from a bug I fixed before sending out v2. It can
just be removed.
I've attached the v3 patch.
David
| Attachment | Content-Type | Size |
|---|---|---|
| v3-use-limit-instead-of-unique-for-distinct.patch | text/plain | 9.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2022-10-13 10:58:30 | Re: hash_xlog_split_allocate_page: failed to acquire cleanup lock |
| Previous Message | Alvaro Herrera | 2022-10-13 10:37:39 | Re: Suppressing useless wakeups in walreceiver |