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 1lLnRn-0000JC-7K for pgsql-general@arkaria.postgresql.org; Mon, 15 Mar 2021 13:39:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lLnRm-0000We-0g for pgsql-general@arkaria.postgresql.org; Mon, 15 Mar 2021 13:39:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lLnRl-0000WX-Jt for pgsql-general@lists.postgresql.org; Mon, 15 Mar 2021 13:39:49 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lLnRj-0007Q0-8X for pgsql-general@lists.postgresql.org; Mon, 15 Mar 2021 13:39:48 +0000 Received: by mail-ej1-x62b.google.com with SMTP id r17so66238539ejy.13 for ; Mon, 15 Mar 2021 06:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=PAIV7DXgeUWUMV01qWX8qY3Q2t4+7zZtvI1J6v/M1FY=; b=I5o4i7ttxmfwdIQ2VU52T/j9pRuKfF9tVNWN4Vm7F23mNJTU/YD2R1VUSggOFQe2vx tZk0irUmaIfXlYE5zjQ9BGX7wA8tJf/yO1PX00sHMzAgQuxBfDjWQFnkGFbYzBa086r7 /7W0Hby4GA2y+0osYgLJ39gnNA/Uyy1uzi/gM3l1sLCvtkW5HvH5yaXBDFbdA5z2D6C2 47Hc4JYTa8cwcBletNqsY0PBVc2tfLNDJ9MMtX0hZV7fxZjZKIIDLaJF/G6YywG76dC8 pyfwGjANjDzdw7HF2LqqkImC1noCozkpS9TwBLZ5m1akE25HN53Q8bJ9jHsWgxEBbreY s02Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=PAIV7DXgeUWUMV01qWX8qY3Q2t4+7zZtvI1J6v/M1FY=; b=Xa8nlopLcHrSTi5at4AOtF5LYtyAEF8hOMngBuwnabhAFTh3CnHna/uioXxRJPqnZQ p9MYxtzt1HecLbDf47A+2evQ4aO4/oFeEdXxPb4ZEdN7Qm9+zgO3x81EoxFalp/+HFEs nFQ00YjugfAtybHOKJep4EGlATks2cBHfPY9q4ta8KhIciyg8k8OBQgUZoa7L4dlF0ZI v9DspdYG/WzVbNiZopHSt5A6p0/ryGkTZQxljWOtu2/9KvXJ1zmY6B3hSxmblFzcLL2T wDjqXx3gbUZeR8KeRSKmB0HUJNZ9Nkuf6QIfY+7kPx/OXNFcIXtMIs2eSgyV3QhTUyfP BUJQ== X-Gm-Message-State: AOAM530uC2N3LXwjZKQ0FkZh+9qMLF6jWWAdDd+YJJsnPZOC1YeFDSLr zeRmSzqzjRrbjuRLnpEC71TZZw== X-Google-Smtp-Source: ABdhPJw/ieDS6hICKYUhkgzqM45SRrsqQ/7KIxx/EzqM/rcCaOxDksF0FTk7z48UtZJQltWi3oiQ9w== X-Received: by 2002:a17:906:4e17:: with SMTP id z23mr23856386eju.439.1615815585420; Mon, 15 Mar 2021 06:39:45 -0700 (PDT) Received: from localhost.localdomain (217-149-171-45.nat.highway.telekom.at. [217.149.171.45]) by smtp.gmail.com with ESMTPSA id s20sm8224828edu.93.2021.03.15.06.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 06:39:45 -0700 (PDT) Message-ID: <8588634ebfd4fa3b0c9a0608e19c30f1cf80c03a.camel@cybertec.at> Subject: Re: Refcursor From: Laurenz Albe To: Yambu , pgsql-general Date: Mon, 15 Mar 2021 14:39:44 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2021-03-15 at 13:58 +0200, Yambu wrote: > May I know why the below takes so long? > > > BEGIN; > select * from func1() ; > fetch all from ""; > end; > > Select * from func1() ; on its own is very fast The second just fetches a cursor for the query, the first executes the query. Executing the query is what can take long. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com