Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dOCs2-0003ch-SZ for pgsql-performance@arkaria.postgresql.org; Fri, 23 Jun 2017 00:54:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dOCs2-0000io-FP for pgsql-performance@arkaria.postgresql.org; Fri, 23 Jun 2017 00:54:46 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dOCs1-0000hH-1u for pgsql-performance@postgresql.org; Fri, 23 Jun 2017 00:54:45 +0000 Received: from mail-vk0-x234.google.com ([2607:f8b0:400c:c05::234]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dOCry-0000jr-R4 for pgsql-performance@postgresql.org; Fri, 23 Jun 2017 00:54:43 +0000 Received: by mail-vk0-x234.google.com with SMTP id r125so7396855vkf.1 for ; Thu, 22 Jun 2017 17:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+B7jUI19KixskEHTVcFNxesz+8THUWxjSlRwVGpD1O4=; b=qxYn9OQr9xq8t2hL92OikhnuK0D8xnYqVAKZ0tLylxaHfWuFOXZV9cqkNYB7LPKrl5 66Gtj+WbSZ1IfT3Y8HT65ShU8GaQ3hqvrQryP+ckCpYkNso1gPoxEdmuOtUra7bBToYk zhIbCJFJvawy8jWyrq8FERKuSlrDxGievJf4SBGsfvfueDmESvh6D5ZrjWbLYcPmsZFD ltmP14uaq92xmhn1ZG20TZcBr5Kemc3VIgTi/3bzDh41OHjp6pZMdKCNYGsGQinXGH+I QLn8vBngF5xmeRDaRlx9thL2AO1UWBM4FwJA+Kd5OuRB8hlU4S1c4U5ICBh4X2gx99SZ XMxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+B7jUI19KixskEHTVcFNxesz+8THUWxjSlRwVGpD1O4=; b=nCUh58wKX6oOv84TQDQhGc25vGbhC7ba7dMgfLwANCdrgJN/lEObeB5Kz6l0LTIkBl +5t6cJbwbW9NAxDMQFrYc9NCnkmovT8MVEExeDpSCpeDWCTMqLSNxMCqcSGfAs3RxHlk gIlGRq8Y56AsoJcxhUhgh0q9JCbBwP67uHwQOExy9DOuGKD0isUo698XBVjRm516QNFn KsXS56l38TmDtrMVcDXK1S2UH4XftZvAafG4ZlQQX2oB6yNh60TwhL5GNtBihnPJ20LW 4ANLPEdSiXtI4iggKE86HMMBsT/UB0FiI1cq/G5Kq9d/+L645VnbPYsbJgnf/IsShr1t qTNw== X-Gm-Message-State: AKS2vOzuqZgTPslbw+K5vVPHQ2/hRr1yRMn01vrOE9bReHYTLXwec2x9 DYW/nH4n/KpPb4vJIUNrKWc+b4Z4nA== X-Received: by 10.31.168.136 with SMTP id r130mr1292772vke.129.1498179282104; Thu, 22 Jun 2017 17:54:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.64.7 with HTTP; Thu, 22 Jun 2017 17:54:41 -0700 (PDT) In-Reply-To: References: From: Dave Stibrany Date: Thu, 22 Jun 2017 20:54:41 -0400 Message-ID: Subject: Re: Dataset is fetched from cache but still takes same time to fetch records as first run To: Sumeet Shukla Cc: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary="001a11415fa6eb79340552960b0a" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --001a11415fa6eb79340552960b0a Content-Type: text/plain; charset="UTF-8" The numbers you posted look exactly as I would expect. The first read hits disk and takes 108ms, the second read hits the cache and takes 27ms. On Thu, Jun 22, 2017 at 8:40 PM, Sumeet Shukla wrote: > Both the first run and subsequent run takes same amount of time. > > *First Run:* > > "Seq Scan on d_payer (cost=0.00..8610.40 rows=121788 width=133) (actual > time=8.760..98.582 rows=121788 loops=1)" > " *Buffers: shared read=2521*" > "Planning time: 16.820 ms" > "Execution time: 108.626 ms" > > > *Second Run:* > > "Seq Scan on d_payer (cost=0.00..8610.40 rows=121788 width=133) (actual > time=0.010..18.456 rows=121788 loops=1)" > " *Buffers: shared hit=2521*" > "Planning time: 0.083 ms" > "Execution time: 27.288 ms" > > > Can anyone please help me understand and fix this. > > > Thanks & Regards, > Sumeet Shukla > > --001a11415fa6eb79340552960b0a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The numbers you posted look exactly as I would expect. The= first read hits disk and takes 108ms, the second read hits the cache and t= akes 27ms.

On Thu,= Jun 22, 2017 at 8:40 PM, Sumeet Shukla <sumeet.k.shukla@gmail.com= > wrote:
B= oth the first run and subsequent run takes same amount of time.

First Run:

"Seq Scan on d_payer (cost=3D0.00..8610.40 rows= =3D121788 width=3D133) (actual time=3D8.760..98.582 rows=3D121788 loops=3D1= )"
"=C2=A0Buffers: shared=C2=A0read=3D2521"
"Planning time: 16.82= 0 ms"
"Execution time: 108.626 ms"


Second R= un:

"Seq Scan on d_payer = (cost=3D0.00..8610.40 rows=3D121788 width=3D133) (actual time=3D0.010..18.4= 56 rows=3D121788 loops=3D1)"
"=C2=A0Buffers: shared=C2=A0hit=3D2521"
&= quot;Planning time: 0.083 ms"
"Execution time: 27.288 ms"=


Can anyone please help me understand and fix this.


Thanks & Regards,
Sumee= t Shukla

<= /div>

--001a11415fa6eb79340552960b0a--