Hey folks.  I found out my wife had a meeting this evening and so I'll have to stay home with our daughter.  Sorry about the late notice.
 
But here is something to chew on:
 
Just upgraded from 7.3.6 to 7.4.2 this past weekend.  We had a query that used to take 20 mins to run......It now takes.....45 secs!  Of course we re-wrote what we had originally done because of the way 7.3.6 handled indexes.  We used the simple query below to spot the problem:
 
7.3.6 queries:
this query worked great.  It used the index on machine_id and date_est:
select *
from cdm.cdm_partnerlog
where
machine_id=100838873
and date_est='2004-04-05'
 
--explain
 Index Scan using cdm_partnerlog_machine_id on cdm_partnerlog  (cost=0.00..1106.38 rows=3 width=76) (actual time=0.39..0.39 rows=0 loops=1)
   Index Cond: (machine_id = 100838873)
   Filter: (date_est = '2004-04-05'::date)
 Total runtime: 0.44 msec
---
This query first did a scan of the entire table using the date_est field and then after it pull the result set then filtered on the machine_id field. This would take a stink load of time due to the number of records:
 
select *
from cdm.cdm_partnerlog
where
machine_id=100838873
and date_est>='2004-04-05'
 
--explain
Index Scan using cdm_partnerlog_date_est on cdm_partnerlog  (cost=0.00..955.45 rows=1 width=76) (actual time=3274.86..3274.86 rows=0 loops=1)
   Index Cond: (date_est >= '2004-04-05'::date)
   Filter: (machine_id = 100838873)
 Total runtime: 3274.93 msec
---
Once we updated to 7.4.2, the query below:
 
select *
from cdm.cdm_partnerlog
where
machine_id=100838873
and date_est>='2004-04-05'
 
 Index Scan using cdm_partnerlog_machine_id on cdm_partnerlog  (cost=0.00..315615.91 rows=62983 width=656) (actual time=0.149..0.149 rows=0 loops=1)
   Index Cond: (machine_id = 100838873)
   Filter: (date_est >= '2004-04-05'::date)
 Total runtime: 0.243 ms
 
SWEEET!

Patrick Hatcher



Patrick Hatcher
Macys.Com
Legacy Integration Developer
415-422-1610 office
HatcherPT - AIM
>From sfpug-owner@postgresql.org Thu Apr 15 18:49:22 2004 X-Original-To: sfpug-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4A7FBD1C9DA for ; Thu, 15 Apr 2004 18:49:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 21306-08 for ; Thu, 15 Apr 2004 18:49:18 -0300 (ADT) Received: from redhotpenguin.com (unknown [64.127.99.50]) by svr1.postgresql.org (Postfix) with ESMTP id 3DE0BD1C9C8 for ; Thu, 15 Apr 2004 18:49:11 -0300 (ADT) Received: (qmail 3507 invoked by uid 509); 15 Apr 2004 21:49:18 -0000 Received: from fred@redhotpenguin.com by www.redhotpenguin.com by uid 505 with qmail-scanner-1.16 (clamscan: 0.65. spamassassin: 2.44. Clear:SA:0(-2.3/5.0):. Processed in 1.273768 secs); 15 Apr 2004 21:49:18 -0000 Received: from c-24-7-88-254.client.comcast.net (HELO ?192.168.0.8?) (fred@redhotpenguin.com@24.7.88.254) by 64.127.99.50 with RC4-SHA encrypted SMTP; 15 Apr 2004 21:49:16 -0000 Mime-Version: 1.0 (Apple Message framework v613) In-Reply-To: <200404121716.00967.josh@agliodbs.com> References: <200404121655.53811.josh@agliodbs.com> <20040413001306.GC29071@fetter.org> <200404121716.00967.josh@agliodbs.com> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Fred Moyer Subject: Elephant costume Date: Thu, 15 Apr 2004 14:49:08 -0700 To: SF Postgres X-Mailer: Apple Mail (2.613) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/11 X-Sequence-Number: 808 So talk of the elephant costume at last night's meeting led me to this page: http://www.funfolly.com/h/mascots/c1744.htm All it needs is a blue cape and PostgreSQL logo embroidered on the front.