Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sV8W2-0087If-RG for pgsql-general@arkaria.postgresql.org; Sat, 20 Jul 2024 11:44:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sV8W0-00FGBe-SZ for pgsql-general@arkaria.postgresql.org; Sat, 20 Jul 2024 11:44:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sV8Vz-00FGBR-Rh for pgsql-general@lists.postgresql.org; Sat, 20 Jul 2024 11:44:40 +0000 Received: from sonic304-20.consmr.mail.sg3.yahoo.com ([106.10.242.210]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sV8Vx-000WwL-2E for pgsql-general@lists.postgresql.org; Sat, 20 Jul 2024 11:44:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1721475872; bh=GJJY3oQXgFpN+oc/1tA/p5kWsPt6bMThIJGtw5JUIho=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To; b=ITvmN/Y862oHQJiCS5iDHTuphrLs5F/rMYxypZu5Od5D+QykzsZw3ehrBxrcYwwRTrN6HvNzNYxzC5iewSxF88au5JtoX9mFnqW4+RQz7gYUUdJEJw2AZe42nRk3Tpja48Y+iyTuCXH/H+HEkWKfG/RjlsS6/1xlAvevFqvmWGmC1AuacR4TZbtMy6GIt6W1eiKM/m2SJATUrW3Jj9VywE8wN+Uh4E3YeLXIxsOyRe/fwJLy2yh3XE6WBgG74aPz6mT8sOHUJRMnfgxa0FPzzABcBbBbgqgzU8ptSJHzXHjLKCcevv+Kinqo6G+craFMQj+5d5iSUcIeksrQsgeKww== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1721475872; bh=5ZXfarFOSlMJZjThpekV8+oFWz5Lt/+zSt63r4+gLaF=; h=X-Sonic-MF:X-Sonic-MF:Date:From:To:Subject:From:Subject; b=qPfrEy/o9HBiGbypiDSD2rc/KY050FaJJ6f72Uc28n0QSC+rFHmx726jUadupqo8Y7ZiHHWOBqQSnGn2+JszOYENfpWen9VfhQR8DyKdgjjeLJsyraHoTi9hGbQZnMyvse1PKkt3G7ckqatRrIFPCZeZdCugPO9pRw5RHOZ9UvRNxGO7ilyNXEbz3KwUfmps3k43QfURyQQJ4Nk8yZp8HpXFwzcHR8X8zNoI9QegkWMTMKFHKxjB7rWsYCLNtop8ORx0KkGlZ84Dsedbcl1r0DTOJI9o1fBNbM3TrjyeEZX5HJmTfop8qOZQFkaATV1Q9Qke3aLXSIqwaG5n7+bONA== X-YMail-OSG: 0Sf_QuAVM1ngrlewpqhs7xJ7jrDpZiru.h5hOVpSmiMSA.M3JBrDP.hId9sV85r tvLX2Wqpmm7i_10yCmFZVFGkyx7e3zfLjD9YWUKIQAZtAChdPrXoQ5q0GWDpLyAdTRefRfQjW34A xIsYY5EUcZfchYkbTfuxY0DtGs4w670vaCul7mNPCoe1y9tOKZi6vHz1aQJdQ0m3KQw7hg_C34Hu mGnINZecWvcvMGN2F_hiKZmmGLSSPo6_7qnArVfUvadVlSlm.4AIwf3u8OH33r9iKd.Vu6AzriR0 RZ7Q.0voMOgQf8.lfo4Pe.IcKKcaQudmqOTmwNw0Nt5O8kQi3djrhwAUON8cyDwb5NvCd_pUl_jm vc4WCIROIDL_cI8Oh6bzpi2c19UqevSC7WZjLVstvcUWf57WjvCttSV_ZjL_H4gE9SGwICIhv_EC LICJe.uAP6GUjtrdZmUyMgEd27VTd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3KIfcWnxFfFAKGyUHr5q9QVQAho4m7TTGz XF4nWHBWYyzLJq3vokqOkGjZHhqXw2cSXWm5LSFSK2lTKPm5eGiP8weKajUXWq7lHkk_zKcUevU. oAZbnmc1WZmD4cFeVyPj.ZX7C91kBV6vZS9gLYjC_hgZGqvV0Awyswodx2CilqwsSPV.Q_CJxzTh pgZAPtKjUC.CbeU.qPilMGme77t5GgIGguu_mEePYB3FVHE7CwoLlRVtveaS2_Rsq2aIE2Hs9AOz sA2.nIzSaUUoFfQC85tpYqKoSdV0MewTSk.zlWrN06xjW48Kz0baSovIsnbj.TG9xSYqAd3oDI2E PXz2xCh2WBkAl4bIVfwMVZCGF7oZD7NSjawz4BA6uerron3RrVq7K8jlaIMuBHku3SXzELsEfPVY 9SnZwfMmf9L08MOYmixW7qyL_UeVxT4yVHzrUwafsDSYkR4mGNuRz065D7p_nsOkYpVpXTgrxIsi BJsFLuXHfkZnbVEI2aVmcCwPWQUTOotHx9.A1WxbeEoAMYBi9ZuTDr6sB1Rrp9TX15WlH.0vaEob HC31OUbaihQm5A7N8zE38D83qdygzBkM1OaQlQG71jCmsrWL3b9gVMxwPFVt5_AKLrdSjOgHfVsb .bauzIQwrA2IIkY5B0vFjXnSyb9oV9_pc6VhOkUreJ5yRe_.dGOfDFfdOg9yGaA1nmWvzQnlc1Ja 5gLNQUnn4s3VoGkHD7fbVO00PIR0vvYtwKVuS3pl62zrTTafPxbGMpnY82aUevbiXaTAjZRrOAtv PV92uH406c8ovM0Xy X-Sonic-MF: X-Sonic-ID: d057a57a-9b69-4dfd-b87e-bf74e0a796f7 Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.sg3.yahoo.com with HTTP; Sat, 20 Jul 2024 11:44:32 +0000 Received: by hermes--production-gq1-799bb7c8cf-b6h6x (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID a012f82acc90cb4d33d69670b77cd920; Sat, 20 Jul 2024 11:44:25 +0000 (UTC) X-YMail-OSG: r.PFo0sV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fc1R0_W6W7noxNn6f2RilJ CvtVvUbe4roGQVlRAlmVA3TA1P3ZwOBNAcMhKdXnVLeL1llWTtFQFXI8lE2e.C1NixL2txPjS5tz pzmLx6JJUCjtgc33M4vV9FfghtsnzuTcBK.g7SMK9BOvgo8.guwK.bmZlZFZgP7VihaMIUopXBnv Jk6gLvhqrEoPbxtOoPWgRrPc1_5SI9tmsJiIez7LGxNYSG.UllGLfXvnH8OXj3yWloTfGZg-- X-Sonic-MF: X-Sonic-ID: 02919b2f-87de-44c3-b0c2-e499b527e6e3 Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.gq1.yahoo.com with HTTP; Sat, 20 Jul 2024 11:44:24 +0000 Date: Sat, 20 Jul 2024 11:44:22 +0000 (UTC) From: "sivapostgres@yahoo.com" Reply-To: "sivapostgres@yahoo.com" To: Francisco Olarte Cc: Postgresql General Group Message-ID: <680243525.2443164.1721475862129@mail.yahoo.com> In-Reply-To: References: <937562047.1752859.1721295502145.ref@mail.yahoo.com> <937562047.1752859.1721295502145@mail.yahoo.com> Subject: Re: Re. Select with where condition times out MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2443163_692248890.1721475862128" X-Mailer: WebService/1.1.22501 YMailNorrin Content-Length: 8313 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------=_Part_2443163_692248890.1721475862128 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Executed=C2=A0VACUUM FULL VERBOSEfollowed byREINDEX DATABASE dbname; It didn't increase the performance, still time out happened.=C2=A0 VACUUM d= idn't find any dead rows in that particular table.=C2=A0=C2=A0 Yes, the actual query and conditions were not given in my first comment.=C2= =A0 Actually where condition is not on the date field alone and the query w= ith current date is only a sample.=C2=A0 =C2=A0 What I did,1.=C2=A0 Took backup (pg_dump) of the database from the server i= t's running.=C2=A0 =C2=A0[ Server config. Xeon Silver 4208, Windows Server = 2019 Standard ]. 2.=C2=A0 Restored in another desktop system, installing PG 11 afresh. 3.=C2=A0 Performance was excellent.=C2=A0 Within milliseconds I got the res= ult.=C2=A0 Application was run from the desktop. 4.=C2=A0 Restored the database in the same server, as another database.=C2= =A0 Improved performance but doesn't match the performance of the desktop.= =C2=A0 Application run from the server itself.=C2=A0=C2=A0 Now server got two databases with exactly the same data.=C2=A0 =C2=A0Old on= e takes more than 15 minutes; newer one takes few seconds.=C2=A0 Applicatio= n run from the server and also from clients.=C2=A0 In both conditions, the = result is same.=C2=A0=C2=A0 What else I need to do to correct this issue? I can easily replace the old database with the backup.=C2=A0 Is that only o= ption? Happiness Always BKR Sivaprakash On Thursday, 18 July, 2024 at 05:23:39 pm IST, Francisco Olarte wrote: =20 =20 On Thu, 18 Jul 2024 at 11:38, sivapostgres@yahoo.com wrote: > Hello, > PG V11 > > Select count(*) from table1 > Returns 10456432 > > Select field1, field2 from table1 where field3> '2024-07-18 12:00:00' > Times out How do you send the query / how does it time out? Is that the real query? Is table a table or a view? What does explain say? > Any possible way(s) to do this? If your client is timing out, increase timeout, if imposible you can try fetching in batches, but more detail would be needed. Suggestions to improve total time had already being given, try to decrease bloat if you have it, but AFAIK timeouts are configurable, so it may just be you have a too low timeout. If it had been working, is field3 indexed? How is the table modified? Because with a configured timeout, whit an unindexed table ( forcing a table scan ) the query may be working for years before you hit the bad spot. Also, the query includes todays date, so I doubt it has been used for years, probably "a similar one has been used for years", and probably that is not your real table ( or you have a naming problem ). Without giving real info, people cannot give you real solutions. Francisco Olarte. =20 ------=_Part_2443163_692248890.1721475862128 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Executed 
VACUUM FULL VERBOSE
followed by
REINDEX DATABASE dbname;

It didn't increase the performance, still time out happened.&nbs= p; VACUUM didn't find any dead rows in that particular table.  

Yes, the actual query and conditions were not given in= my first comment.  Actually where condition is not on the date field = alone and the query with current date is only a sample.   
<= div dir=3D"ltr" data-setdir=3D"false">
What I did,
1. = ; Took backup (pg_dump) of the database from the server it's running. =  [ Server config. Xeon Silver 4208, Windows Server 2019 Standard ].2.  Restored in another desktop system, installing PG 11 afresh.
= 3.  Performance was excellent.  Within milliseconds I got the res= ult.  Application was run from the desktop.
4.  Restored the d= atabase in the same server, as another database.  Improved performance= but doesn't match the performance of the desktop.  Application run fr= om the server itself.  

Now server got two databases with = exactly the same data.   Old one takes more than 15 minutes; newe= r one takes few seconds.  Application run from the server and also fro= m clients.  In both conditions, the result is same.  
<= div dir=3D"ltr" data-setdir=3D"false">
What else I need to do to correct this issue?

I can easily replace the old database with the backup.  Is that only = option?

Happiness Always
BKR Sivaprakash

=20
=20
On Thursday, 18 July, 2024 at 05:23:39 pm IST, Fran= cisco Olarte <folarte@peoplecall.com> wrote:


=20 =20
On Thu, 18 Jul 2024 at 11:38, sivapostgres@yahoo.com
<sivapostgres@yahoo.com> wrote:
>= ; Hello,
> PG V11
>
> Select count(*) from table1
> Returns 104564= 32
>
> Select field1, field2 from= table1 where field3> '2024-07-18 12:00:00'
> Times= out

How do you send the query / how d= oes it time out? Is that the real
query? Is table a table= or a view? What does explain say?


> Any possible way(s) to do = this?


If your client is timing o= ut, increase timeout, if imposible you can
try fetching i= n batches, but more detail would be needed.

Suggestions to improve total time had already being given, try to
decrease bloat if you have it, but AFAIK timeouts are config= urable, so
it may just be you have a too low timeout.

If it had been working, is field3 indexed= ? How is the table modified?

Because w= ith a configured timeout, whit an unindexed table ( forcing a
table scan ) the query may be working for years before you hit the bad=
spot. Also, the query includes todays date, so I doubt i= t has been
used for years, probably "a similar one has be= en used for years", and
probably that is not your real ta= ble ( or you have a naming problem ).
Without giving real= info, people cannot give you real solutions.

Francisco Olarte.
<= br clear=3D"none">
------=_Part_2443163_692248890.1721475862128--