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 1sVnBL-00BfAp-1X for pgsql-general@arkaria.postgresql.org; Mon, 22 Jul 2024 07:10:03 +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 1sVnBI-00Flxm-PZ for pgsql-general@arkaria.postgresql.org; Mon, 22 Jul 2024 07:10:01 +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 1sVnBI-00Flx9-8g for pgsql-general@lists.postgresql.org; Mon, 22 Jul 2024 07:10:00 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sVnBF-000oja-BU for pgsql-general@lists.postgresql.org; Mon, 22 Jul 2024 07:09:59 +0000 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2eeec60a324so51515491fa.2 for ; Mon, 22 Jul 2024 00:09:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peoplecall-com.20230601.gappssmtp.com; s=20230601; t=1721632195; x=1722236995; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DcA7xzqeaLWjW9b/NN1Lpucj4QUuQmET12lYxbIjdS0=; b=jjLa9a+k//1C7f27WYTjeEOC/do9veadl8PeEuT6NI4f6pAdglFexV8jGeXRYTNoSc AcKxCDncwx5ckrz+5OY8fNz56zp4BGRy5zUOqFnzCryZWugfx55MML7vRKBg/bbjz6yT InaK/odzVs6vvYleoxPh+S7ELppLPUdcNw7ciM05Ic0bBvQGkK3N7Sn4SOyiyT3QDQKb Uxi0s8KRuGEWqp69R+66xogFqULCtP9T+HxsYy5M0KJiAdiq1QlPVn+wInMdcSRIgNee cXW4EOy0fU+A0adEUVk7RWBF452l3Q3QZqxaWkoy2uJmH/aHcfiRWlW+sPfGPb946Gcz pOBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721632195; x=1722236995; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DcA7xzqeaLWjW9b/NN1Lpucj4QUuQmET12lYxbIjdS0=; b=v6sJLGC4GiY7mHP+HXNiCflzXfaJGd/8gDNV7zhQ5EJu155qMcZS5xwkHoXLt8tg7R xi/riMzmSIfUYnYSkt8XSqB2FEGEpBM3Vd8XhPsGizgEb3ZapfsxKtytBaqXndB15w1M 35HxXEB57KgqEIkU6JV+CI3WRbM095LoYXt5gecrpKsQHawZLFIfNB3lD/iM09fWErmB PtWEihCaZJbiryw37IzCk+v8ezguFgWJ1rGsrLMdFvyYKvGVGVNFuaiSrh0/yl5kkMRP tSKVir0psjDJ2KT8aJX1qrUgDCXq8cV8XtCSlnUX5KyzdKMofoXsN1I4UZswNkMduL29 nA7g== X-Gm-Message-State: AOJu0Yz98+lKqQtp0w+f1uL1CSEKu4xhC4KozvHtAyUYiFFiSFy5VOgt 34gW8u7a26psHj3Mp3PlE4rIgVS1DeEK1zVgk7Krj94Sf1XG3wjI87/sBZr3LZozvIya94J8NUf NILK/unZI+T1Nc6AmWOP/eQWBbBwxPkXVVIM5 X-Google-Smtp-Source: AGHT+IFc57nPmafqfFQWQJMi3DrLWg5jGlUdjhFw4GT1ZfzDAXhIstZUSspasV/057DwXdELNdpUbh4bf1GtFrT8Cco= X-Received: by 2002:a05:651c:1a2c:b0:2ef:2b65:1d03 with SMTP id 38308e7fff4ca-2ef2b651e57mr32207391fa.49.1721632195204; Mon, 22 Jul 2024 00:09:55 -0700 (PDT) MIME-Version: 1.0 References: <937562047.1752859.1721295502145.ref@mail.yahoo.com> <937562047.1752859.1721295502145@mail.yahoo.com> <680243525.2443164.1721475862129@mail.yahoo.com> <676910651.2764306.1721624881495@mail.yahoo.com> In-Reply-To: <676910651.2764306.1721624881495@mail.yahoo.com> From: Francisco Olarte Date: Mon, 22 Jul 2024 09:09:19 +0200 Message-ID: Subject: Re: Re. Select with where condition times out To: "sivapostgres@yahoo.com" Cc: Postgresql General Group Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Trying to trim to still relevant parts, as mail is becoming extremely hard to read. On Mon, 22 Jul 2024 at 07:08, sivapostgres@yahoo.com wrote: > Actual Query: > select source_node_id, create_time from sym_data where table_name =3D 't= x_combined_sales_header' and ((event_type =3D 'I' and row_data like '"F92DD= 7AA237A45D99CA5741DF73EA3D1"%') or (event_type in ('U', 'D') and pk_data li= ke '"F92DD7AA237A45D99CA5741DF73EA3D1"')) and create_time >=3D '2024-07-18 = 01:43:32.981' order by create_time desc That is a complex query, you should probably insure tables are properly analized, show your indexes and show explain, explain analyze if possible, on both servers. ... > I thought I'm clear. My bad. > > 2 computers were involved in total. One Xeon Server with Windows 2019 St= andard and other one is Intel i5 based Desktop with Windows 10. > I took backup (pg_dump) from windows server machine. > And restored in the same server as another database. Now we have 2 datab= ases with identical data in Windows Server. The actual query (given above) = is taking more than 15 min in the original database and takes a second in t= he restored database. Assuming same cluster ( same postgres instance ) explain may shed some ligh= t. > I have done Vacuum, Re-Index in the original database. No improvement. An= ything else that I can do to make the original database to perform just lik= e the restored database? Insure analyze is the same in both. Test using explain. If you peruse the archives you will notice explain output is what tells people what the server is doing. IIRC explain (analyze,buffers) on both will show how the query was done and where the time was spent. > > I can easily replace the old database with the backup. Is that only op= tion? > Ah, one clue. From the info I have in this and previous mails, that is > the only option for me. Having more info someone may have ideas, but ... > What else ? Use explain, send appropriate info. You may have noticed there are few responses to your mail. This is probably due to people not being able to provide too meaningful help with the data you provide and not willing to try taking blind shots. Postgres is a very complex piece of software, and even includes some randomization when optimizing very complex queries, which is not your case. With a query like yours having different times in similar databases the first thing to do will be analyze both, explain analyze on both, compare the results, to ensure both databases are doing the same operation. If they are, then it is time to see why the old one does it slower ( I assume you are not testing a busy production server against an idling backup). If they do not, then the path to follow is to compare plans and try to know why they differ. > Regards. > Francisco Olarte. As an aside, I would personally appreciate it if you delete my signature from the end of your message when replying to one sent by me. Francisco Olarte.