X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 221FC9FB282 for ; Wed, 23 Aug 2006 15:02:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 25034-06 for ; Wed, 23 Aug 2006 18:02:39 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mxca2.corp.netopia.com (mx-us-west.netopia.com [65.206.239.221]) by postgresql.org (Postfix) with ESMTP id BD96A9FB1F4 for ; Wed, 23 Aug 2006 15:02:38 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Query tuning Date: Wed, 23 Aug 2006 11:02:35 -0700 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Query tuning Thread-Index: AcbGYQWSAK4siVLFSauOjys2kaoL6wAeMdgQ From: "Subbiah, Stalin" To: "Chris" Cc: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.816 tagged_above=0 required=5 tests=SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: *** X-Archive-Number: 200608/376 X-Sequence-Number: 20561 I get the same plan after running vacuum analyze. Nope, I don't have index on objdomainid, objid and userdomainid. Only eventime has it. -----Original Message----- From: Chris [mailto:dmagick@gmail.com]=20 Sent: Tuesday, August 22, 2006 8:06 PM To: Subbiah, Stalin Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Query tuning Subbiah, Stalin wrote: > Actually these servers will be upgraded to 8.1.4 in couple of months. even so, you could get some bad data in there. http://www.postgresql.org/docs/8.0/static/release.html . Go through the old release notes and you'll find various race conditions, crashes etc. > Here you go with explain analyze. >=20 > # explain analyze SELECT * > FROM EVENTLOG > WHERE EVENTTIME>'07/23/06 16:00:00' AND EVENTTIME<'08/22/06 16:00:00' > AND (OBJDOMAINID=3D'tzRh39d0d91luNGT1weIUjLvFIcA'=20 > OR OBJID=3D'tzRh39d0d91luNGT1weIUjLvFIcA'=20 > OR USERDOMAINID=3D'tzRh39d0d91luNGT1weIUjLvFIcA') > ORDER BY EVENTTIME DESC, SEQUENCENUM DESC LIMIT 500 OFFSET 500; > =20 > QUERY PLAN >=20 > ---------------------------------------------------------------------- > -- > ---------------------------------------------------------------------- > -- > ---------------------------------------------------------------------- > -- > ---------------------------------------------------------------------- > -- > ------------------------------------------------------------- > Limit (cost=3D15583110.14..15583111.39 rows=3D500 width=3D327) = (actual > time=3D427771.568..427772.904 rows=3D500 loops=3D1) > -> Sort (cost=3D15583108.89..15618188.88 rows=3D14031998 = width=3D327)=20 > (actual time=3D427770.504..427771.894 rows=3D1000 loops=3D1) > Sort Key: eventtime, sequencenum > -> Seq Scan on eventlog (cost=3D0.00..2334535.17=20 > rows=3D14031998 > width=3D327) (actual time=3D10.370..190038.764 rows=3D7699388 = loops=3D1) > Filter: ((eventtime > '2006-07-23 16:00:00'::timestamp=20 > without time zone) AND (eventtime < '2006-08-22 16:00:00'::timestamp=20 > without time zone) AND (((objdomainid)::text =3D > 'tzRh39d0d91luNGT1weIUjLvFIcA'::text) OR ((objid)::text =3D > 'tzRh39d0d91luNGT1weIUjLvFIcA'::text) OR ((userdomainid)::text =3D > 'tzRh39d0d91luNGT1weIUjLvFIcA'::text))) > Total runtime: 437884.134 ms > (6 rows) If you analyze the table then run this again what plan does it come back with? I can't read explain output properly but I suspect (and I'm sure I'll be corrected if need be) that the sort step is way out of whack and so is the seq scan because the stats aren't up to date enough. Do you have an index on objdomainid, objid and userdomainid (one index per field) ? I wonder if that will help much. -- Postgresql & php tutorials http://www.designmagick.com/