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 1sVDpv-008fS6-AR for pgsql-general@arkaria.postgresql.org; Sat, 20 Jul 2024 17:25:35 +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 1sVDps-000SlI-TO for pgsql-general@arkaria.postgresql.org; Sat, 20 Jul 2024 17:25:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sVDps-000Sl8-EJ for pgsql-general@lists.postgresql.org; Sat, 20 Jul 2024 17:25:32 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sVDpp-000aEi-VK for pgsql-general@lists.postgresql.org; Sat, 20 Jul 2024 17:25:31 +0000 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2eede876fccso36139671fa.1 for ; Sat, 20 Jul 2024 10:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peoplecall-com.20230601.gappssmtp.com; s=20230601; t=1721496329; x=1722101129; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=rgYW+5qiQMlRPhNiRCZ19Phxc1UZ12SSREujSFg7P0Q=; b=LRNUfiNeNk8fh9yYcnaDp4Pg9AmkVQBsK5H0YH/LiUeZOImCmzboPuVJAswwZrrBmD fKk8VkUW02n2tJxNLu99k47E+3qWB3JhhcldHqCPevgLMYHvLlLPXmfzmy/9Ku02x72g VSPSagmirjo8IRjVdWLJcZGQpVoydUVxuxcbSh8XvrIznJAUBajXHAwFZRB+sXMFynF1 o8W2HKWdgBUekOGS8RHtAR3IV/loc8iU1Di01QkEeGAuAM7ZwvPeKUs29eKJRjBameQB wbkLXXyPR/c1KPWIXOTrG8bWA7dW8kvpmZuNdIqC897zHShiLm7tUjaDHP+U77T3K95k CkCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721496329; x=1722101129; h=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=rgYW+5qiQMlRPhNiRCZ19Phxc1UZ12SSREujSFg7P0Q=; b=EOXwDIEvEONXFwwhUIMFqS7z6TXN+gsfyje9a528FeZsNfnTmtfMYCeMbK1f1wyq+L 9S9hdaF54cJtEpoGPCuvhOHHkCPTVj3EQGDyb2lWo5cWHED9uPUyZTarsL1lFbdZPfPv +eGWuih2TsO8B1nBGbCWFHReppzOfsJMLFAM8xl2J7e6+j/W++AzIVQSb+nmu/dVQoQT hzFxPpd4LVNqRBb155yVpzPbMoOu4DJ8enmRlDRVsu+0SfijTB2689kFeWd2DZoffgLd Xb02RcUk82Clwp2PlmMBN7XVxrfg8q9ZQ7PwpUBOSfcRXs1F2zHSE0lketEz5lNzNA3H XfdQ== X-Gm-Message-State: AOJu0YyNUzCzaLeAsUR4eU6Yxu8bBCnmfCwd1DD2gaytmCe+oCFmtuVF FTllwTdhJevvqmvAocTquy5PexcVwnvw8sSGMec/i6iIhheq82KYKrqBZ+2W82X+HzerU5a3Meo Y5A2SvomBFqy7uETSMQjXVKSOdGaJsr3k0sco X-Google-Smtp-Source: AGHT+IEoUTESVOOx8wBOy7ytFbIoeXDYKZY17icP2o8mCCtr9k0B5CQSi43h/mEeajG9lE13I2ui/dwg5IQt5LSBH5M= X-Received: by 2002:a2e:88d8:0:b0:2ee:8d9a:8ce with SMTP id 38308e7fff4ca-2ef167843b8mr19967231fa.13.1721496328543; Sat, 20 Jul 2024 10:25:28 -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> In-Reply-To: <680243525.2443164.1721475862129@mail.yahoo.com> From: Francisco Olarte Date: Sat, 20 Jul 2024 19:24:52 +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" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi: Please, avoid top posting, specially when replying to long mail with various points,m it makes it nearly impossible to track what you are replying to. On Sat, 20 Jul 2024 at 13:44, sivapostgres@yahoo.com wrote: > Executed > VACUUM FULL VERBOSE > followed by > REINDEX DATABASE dbname; As it has been already said, vacuum full implies reindex ( it basically copies old table to a new one, including indexes, swaps them, deletes old one ). > It didn't increase the performance, still time out happened. VACUUM didn't find any dead rows in that particular table. The no dead rows is the interesting part. > 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. Then they are worthless and harmful. Query time problems is normally data and statistics dependent and always query dependent. The query you posted has only two ways to be done, and few ways to be improved. Suggestions for it will probably be harmful for other queries. > 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 result. Application was run from the desktop. > 4. Restored the database in the same server, as another database. Improved performance but doesn't match the performance of the desktop. Application run from the server itself. What you did not: - Show your tables and indexes. - Show your real queries. - Tell us what "the application is" ( i.e., "psql", "a java app using JDBC", ... ) > Now server got two databases with exactly the same data. Old one takes more than 15 minutes; newer one takes few seconds. Application run from the server and also from clients. In both conditions, the result is same. After what has been happening, I have to ask. Do you mean ONE server with two databases, or TWO servers with one database each? Also, what are the especs of the server and the desktops, and the postgres configuration on each? A misconfigured server can easily send query time through the roof ( i.e., DB servers want real RAM, if you configure postgres with too much mem and it swaps you can make a query really slow ) > What else I need to do to correct this issue? No clue. > I can easily replace the old database with the backup. Is that only option? 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 so far the only thing I have concluded is three databases, fast in server, slow in server and desktop, test only. So my only options are fast server and slow server. So my solution would be "use fast server". As I said, maybe having more data we could suggest "analyze that table with these parameters", or "make this index" or "rewrite this condition in this way", but this is impossible to do with the data you provided. Regards. Francisco Olarte.