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 1nbW1H-0000gN-2D for pgsql-sql@arkaria.postgresql.org; Mon, 04 Apr 2022 23:21:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbW1F-0000gy-6m for pgsql-sql@arkaria.postgresql.org; Mon, 04 Apr 2022 23:21:57 +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 1nbW1E-0000gd-SN for pgsql-sql@lists.postgresql.org; Mon, 04 Apr 2022 23:21:56 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nbW1C-00031h-1y for pgsql-sql@lists.postgresql.org; Mon, 04 Apr 2022 23:21:56 +0000 Received: by mail-ej1-x629.google.com with SMTP id l26so6805167ejx.1 for ; Mon, 04 Apr 2022 16:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=2znvLJ8+EOt5tUMcWcJt5Kw5VoSnQKBIQZHRWmw7O+U=; b=d4MORudzT9/SBJP6mVW12in0Z8H/66Icgp9uFkaJORDHFWSji4ePuBsHznvaUUaa0Y +EaBPLEgTxYfZhh+6Kqe6vKa3hOXEq2cuNYd74lkDZqEZREDqtly17wiB/6+WzyXxbME K4x0wBnbJZ/p6ImGmPB31y9XaG1UlN5eVbLijKqex5n7s6Uqcx1Gh1bhrpP26iUdgWtE sA1nGtNfvkuzJ79BlDFMNXSFDYnRz0dZ3latV7Z/xsILs0oTPM6s/dXO5QKNZu4nOVe9 TBlvHO4t0mgj8SdEH10HafAAbjzmJTHjdMyFbjWILFcDcW+X7aSPBD2tEHhct83Zc+qj FnDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=2znvLJ8+EOt5tUMcWcJt5Kw5VoSnQKBIQZHRWmw7O+U=; b=36WVJXJGG8w1CZJW6xLQl0SGFFNbRkka1kH3VWKUScy/t+ZXwW7FbCPZasGI46QLhc Y/r0Lgf/KKzO6xid0vfA4Od3xJtRY2CsChHwXGPcwNwJFE3HNmp1BAjBSX0E5wq18+4L RqezriGTclknjbUJbnr1CCJwzJbt1/dhDVN3/NXVMnXNtqErI6It5mY8gJ1uDsLnsTxz QMzfo2QWU3s0/HMRYRZKXIbfBYur1iAH7GI0bkNHxiDkQyS84vl5LFO4hlvpe6bm7tjS chdly/9pXsqSUo8985S++QT/s/M5PrZJkb9xfbxKL555mRGRf6Mh/zy7r4kw9QhdfMWd CFJw== X-Gm-Message-State: AOAM5304I15vh2HRGKwesbPAsWQ4R68qJdIixzrnM4w6WtZREhCaMbPy LLKhMJYeM+tTYzfFz8qxCBOCmi0YXXiZVflZrUfwsvWt X-Google-Smtp-Source: ABdhPJzxFNW7xgMof4/Ai6+MwKoW+ICHxQd6Rb9mp4QuU+FV+kMorR7899OnVrYjzAcHC7IaMQX+cvRxYoZ8/hHd6yk= X-Received: by 2002:a17:907:7e93:b0:6e0:8c4f:b53 with SMTP id qb19-20020a1709077e9300b006e08c4f0b53mr600469ejc.454.1649114513333; Mon, 04 Apr 2022 16:21:53 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a54:3049:0:0:0:0:0 with HTTP; Mon, 4 Apr 2022 16:21:52 -0700 (PDT) In-Reply-To: <3817c56b-458d-5295-e8bc-1001231dc5c8@gmail.com> References: <3817c56b-458d-5295-e8bc-1001231dc5c8@gmail.com> From: Shaozhong SHI Date: Tue, 5 Apr 2022 00:21:52 +0100 Message-ID: Subject: Re: How to just get the last in a recursive query To: Rob Sargent Cc: "pgsql-sql@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000c2e27305dbdc646f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c2e27305dbdc646f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 =C2=B7 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 > --000000000000c2e27305dbdc646f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable That is not the most efficient in this case.
How to tell query to delib= erately miss out all except the last one is of interest.
Regards,= David

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


---------- Forwarded messag= e ---------
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= >


In this example,=C2=A0Network Walking in PostGIS =C2=B7 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
--000000000000c2e27305dbdc646f--