X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 83DE9DB9C0 for ; Thu, 24 Nov 2005 09:06:56 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09065-06 for ; Thu, 24 Nov 2005 13:06:56 +0000 (GMT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id 6BFC4DB939 for ; Thu, 24 Nov 2005 09:06:51 -0400 (AST) Received: from hotmail.com (bay101-f8.bay101.hotmail.com [64.4.56.18]) by svr2.postgresql.org (Postfix) with ESMTP id C3A6CF0BA3 for ; Thu, 24 Nov 2005 13:06:54 +0000 (GMT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 24 Nov 2005 05:06:49 -0800 Message-ID: Received: from 64.4.56.200 by by101fd.bay101.hotmail.msn.com with HTTP; Thu, 24 Nov 2005 13:06:48 GMT X-Originating-IP: [84.210.10.106] X-Originating-Email: [bealach_na_bo@hotmail.com] X-Sender: bealach_na_bo@hotmail.com From: "Bealach-na Bo" To: pgsql-performance@postgresql.org Subject: Very slow queries - please help. Date: Thu, 24 Nov 2005 13:06:48 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-OriginalArrivalTime: 24 Nov 2005 13:06:49.0106 (UTC) FILETIME=[EE08A720:01C5F0F7] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.919 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, MSGID_FROM_MTA_HEADER=0] X-Spam-Score: 1.919 X-Spam-Level: * X-Archive-Number: 200511/491 X-Sequence-Number: 15748 Hi Folks, I'm new to Postgresql. I'm having great difficulties getting the performance I had hoped for from Postgresql 8.0. The typical query below takes ~20 minutes !! I hope an expert out there will tell me what I'm doing wrong - I hope *I* am doing something wrong. Hardware -------- Single processor, Intel Xeon 3.06 GHz machine running Red Hat Ent. 4. with 1.5 GB of RAM. The machine is dedicated to running Postgresql 8.0 and Apache/mod_perl etc. The database is being accessed for report generation via a web form. The web server talks to Pg over TCP/IP (I know, that I don't need to do this if they are all on the same machine, but I have good reasons for this and don't suspect that this is where my problems are - I have the same poor performance when running from psql on the server.) Database -------- Very simple, not fully normalized set of two tables. The first table, very small (2000 lines of 4 cols with very few chars and integers in in col). The other quite a bit larger (500000 lines with 15 cols. with the largest fields ~ 256 chars) Typical query ------------ SELECT n.name FROM node n WHERE n.name LIKE '56x%' AND n.type='H' AND n.usage='TEST' AND n.node_id NOT IN (select n.node_id FROM job_log j INNER JOIN node n ON j.node_id = n.node_id WHERE n.name LIKE '56x%' AND n.type='H' AND n.usage='TEST' AND j.job_name = 'COPY FILES' AND j.job_start >= '2005-11-14 00:00:00' AND (j.job_stop <= '2005-11-22 09:31:10' OR j.job_stop IS NULL)) ORDER BY n.name The node table is the small table and the job_log table is the large table. I've tried all the basic things that I found in the documentation like VACUUM ANALYZE, EXPLAIN etc., but I suspect there is something terribly wrong with what I'm doing and these measures will not shave off 19 min and 50 seconds off the query time. Any help and comments would be very much appreciated. Bealach