Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbW42-0000lE-DV for pgsql-sql@arkaria.postgresql.org; Mon, 04 Apr 2022 23:24:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbW41-00034B-93 for pgsql-sql@arkaria.postgresql.org; Mon, 04 Apr 2022 23:24:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbW40-000342-VT for pgsql-sql@lists.postgresql.org; Mon, 04 Apr 2022 23:24:49 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nbW3y-000335-0n for pgsql-sql@lists.postgresql.org; Mon, 04 Apr 2022 23:24:48 +0000 Received: by mail-pl1-x631.google.com with SMTP id n9so4729300plc.4 for ; Mon, 04 Apr 2022 16:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to; bh=1AZOtVNC5G7jKCBNIuNbzvsBpYZ/R36SfBNF7lu+Qow=; b=NQrVP7P7aGx0KCI8xPGFvaC7G28whiXPMW3sbFCRJGB3psAj3YBJ0Txq70Ei4T5PdZ MA0dfM6cwXuNU0Ahz85grHId7Nc7lsbSsLWJicGuVit8Iy/MYrPyV6ApdrvE+sbCyYwQ nFz7mVkJGoZieisEsqA2QjbgvPGA5NvigHhjOpxsDfQxrApvdk2QSIaxNm9/amyEqWe1 Gw/Vu7Z8uXcJg2ly3UzERtNogpulWqbMkl3cinytHgmajB9UZNzR699DHpu/NrPRcxM/ UeUGG2zUsEvI9B797qgyVzWKbBZSeUzK+D7IbyhM7lUcciHeBOEoRvX0l44UEUd9msG9 N1Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to; bh=1AZOtVNC5G7jKCBNIuNbzvsBpYZ/R36SfBNF7lu+Qow=; b=WqOc47JOlFTI1vxEjMJ4mwJesEAmWLvbhPdxz9ekxckGbEQr3BvHkDX7UQpgvxUjbw yrXFjFCHpAbAQb7Zq7T7veorvkrHK9HqLlOocPiUYCAix+CGwX6Ir/ip4DINs0adDV8c ijI+ny1Co4uqVEzFblhZggVZPPmFmBnun+sBW2Kd+wTRfLh5lgOZT8pY2nd34NIH5YMu KXY7BgY4TAHbkQ6JykgLYTBMtR+yaPYbdTC+MUH4J0JVKYQ+fA1Lvw4b9f4Ybx90e4Hd X3WbyadpdV2xNISv/cXRv3G8NCWXGjRtCdTNtmbJmJXtWKBhKUDRDAfu1xY0sE9i05G1 VL9Q== X-Gm-Message-State: AOAM532/xKEdHmR8WO4cKLfDhLeA6NWY3tMw24xv+HnMuhf+sP/JOG8J aXpmoOe/l+R2vdUIvmw3kPA= X-Google-Smtp-Source: ABdhPJzxN+AoOwTucG57sezLymJBrPGmRYqdIGtYgP+qmUL0zhDc6crICc/56UJGFPL94GgC49cvpg== X-Received: by 2002:a17:903:248:b0:155:e8c6:8770 with SMTP id j8-20020a170903024800b00155e8c68770mr459913plh.129.1649114683715; Mon, 04 Apr 2022 16:24:43 -0700 (PDT) Received: from [10.128.71.194] ([155.98.131.2]) by smtp.gmail.com with ESMTPSA id z20-20020aa78894000000b004fb11506899sm13490679pfe.139.2022.04.04.16.24.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Apr 2022 16:24:43 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------PjVdkJ4CSxgl9WD6BSmwTOtm" Message-ID: <524d8959-47c1-4ea7-92cf-8c946f56b428@gmail.com> Date: Mon, 4 Apr 2022 17:24:42 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: How to just get the last in a recursive query Content-Language: en-CA To: Shaozhong SHI Cc: "pgsql-sql@lists.postgresql.org" References: <3817c56b-458d-5295-e8bc-1001231dc5c8@gmail.com> From: Rob Sargent In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------PjVdkJ4CSxgl9WD6BSmwTOtm Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/4/22 17:21, Shaozhong SHI wrote: > That is not the most efficient in this case. > How to tell query to deliberately miss out all except the last one is > of interest. > Regards, David > > On Monday, 4 April 2022, Rob Sargent wrote: > > On 4/4/22 16:14, Shaozhong SHI wrote: >> >> >> ---------- Forwarded message --------- >> From: *Shaozhong SHI* >> Date: Mon, 4 Apr 2022 at 23:13 >> Subject: How to just get the last in a recursive query >> To: PostGIS Users Discussion >> >> >> In this example, Network Walking in PostGIS · Paul Ramsey >> (cleverelephant.ca) >> >> >> 3 rows got returns as follows: >> >> |id --- 6 3 1| >> || >> |How to just get the last (namely, 1) in the most efficient way?| >> Regards, David > reverse the order of the last query and set limit 1 > Don't top post And your definition of "last" is what, exactly --------------PjVdkJ4CSxgl9WD6BSmwTOtm Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 4/4/22 17:21, Shaozhong SHI wrote:
That is not the most efficient in this case.
How to tell query to deliberately miss out all except the last one is of interest.
Regards, David

On Monday, 4 April 2022, Rob Sargent <robjsargent@gmail.com> wrote:
On 4/4/22 16:14, Shaozhong SHI wrote:


---------- Forwarded message ---------
From: Shaozhong SHI <shishaozhong@gmail.com>
Date: Mon, 4 Apr 2022 at 23:13
Subject: How to just get the last in a recursive query
To: PostGIS Users Discussion <postgis-users@lists.osgeo.org>



3 rows got returns as follows:

 id
---
  6
  3
  1

How to just get the last (namely, 1) in the most efficient way?
Regards, David
reverse the order of the last query and set limit 1
Don't top post

And your definition of "last" is what, exactly

--------------PjVdkJ4CSxgl9WD6BSmwTOtm--