Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A503B9FB399 for ; Fri, 20 Jul 2007 12:43:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 18784-10 for ; Fri, 20 Jul 2007 12:43:54 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from crestone.coronasolutions.com (crestone.coronasolutions.com [66.45.104.24]) by postgresql.org (Postfix) with ESMTP id 073A69FBDBB for ; Fri, 20 Jul 2007 12:43:54 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by crestone.coronasolutions.com (Postfix) with ESMTP id 3E8AA64497E; Fri, 20 Jul 2007 09:43:52 -0600 (MDT) Received: from crestone.coronasolutions.com ([127.0.0.1]) by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26983-06; Fri, 20 Jul 2007 09:43:51 -0600 (MDT) Received: from mac.local (c-76-25-77-161.hsd1.co.comcast.net [76.25.77.161]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by crestone.coronasolutions.com (Postfix) with ESMTP id 1E462644973 for ; Fri, 20 Jul 2007 09:43:51 -0600 (MDT) Message-ID: <46A0D836.5090806@drivefaster.net> Date: Fri, 20 Jul 2007 09:43:50 -0600 From: Dan Harris User-Agent: Thunderbird 2.0.0.4 (Macintosh/20070604) MIME-Version: 1.0 To: PostgreSQL Performance Subject: Simple query showing 270 hours of CPU time Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at coronasolutions.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/259 X-Sequence-Number: 25943 Today, I looked at 'top' on my PG server and saw a pid that reported 270 hours of CPU time. Considering this is a very simple query, I was surprised to say the least. I was about to just kill the pid, but I figured I'd try and see exactly what it was stuck doing for so long. Here's the strace summary as run for a few second sample: % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 97.25 0.671629 92 7272 semop 1.76 0.012171 406 30 recvfrom 0.57 0.003960 66 60 gettimeofday 0.36 0.002512 28 90 sendto 0.05 0.000317 10 32 lseek 0.01 0.000049 1 48 select ------ ----------- ----------- --------- --------- ---------------- 100.00 0.690638 7532 total Here's the query: select id from eventkeywords where word = '00003322' If I run the query manually, it completes in about 500ms, which is very reasonable. There are 408563 rows in this table. I just noticed there is no index on word ( there should be! ). Would this have caused the problem? This is 8.0.12 Linux sunrise 2.6.15-26-amd64-server #1 SMP Fri Sep 8 20:33:15 UTC 2006 x86_64 GNU/Linux Any idea what might have set it into this loop? -Dan