X-Original-To: pgsql-admin-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 0A91B9FB3C5; Thu, 24 Aug 2006 01:44:43 -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 25516-08; Thu, 24 Aug 2006 04:44:23 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- 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 034869FB37A; Thu, 24 Aug 2006 01:44:22 -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: [PERFORM] Query tuning Date: Wed, 23 Aug 2006 21:44:20 -0700 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Query tuning Thread-Index: AcbHCqr+SYuxBW/KQFGLN6rhjCMMigALMnRw From: "Subbiah, Stalin" To: "Dave Dutcher" 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/259 X-Sequence-Number: 22802 Changing limit or offset to a small number doesn't have any change in plans. Likewise enable_seqscan to false. They still take 8-10 mins to runs.=20 -----Original Message----- From: Dave Dutcher [mailto:dave@tridecap.com]=20 Sent: Wednesday, August 23, 2006 4:20 PM To: Subbiah, Stalin Cc: pgsql-performance@postgresql.org Subject: RE: [PERFORM] Query tuning It seems to me that what would work best is an index scan backward on the eventtime index. I don't see why that wouldn't work for you, maybe the planner is just esitmating the seq scan and sort is faster for some reason. What does EXPLAIN say if you use a small limit and offset like 10? Or what does EXPLAIN say if you first run "set enable_seqscan=3Dfalse;" = (If you get the same plan, then I wouldn't bother running EXPLAIN ANALYZE, but if you get a different plan I would run EXPLAIN ANALYZE to see if the new plan is any faster.) > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Subbiah,=20 > Stalin > Sent: Wednesday, August 23, 2006 1:03 PM > To: Chris > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Query tuning >=20 >=20 > I get the same plan after running vacuum analyze. Nope, I don't have=20 > index on objdomainid, objid and userdomainid. Only eventime has it. >=20 > -----Original Message----- > From: Chris [mailto:dmagick@gmail.com] > Sent: Tuesday, August 22, 2006 8:06 PM > To: Subbiah, Stalin > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Query tuning >=20 > Subbiah, Stalin wrote: > > Actually these servers will be upgraded to 8.1.4 in couple > of months. >=20 > even so, you could get some bad data in there. > http://www.postgresql.org/docs/8.0/static/release.html . Go through=20 > the old release notes and you'll find various race conditions, crashes > etc. >=20 > > 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' >=20 > > 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 > >=20 > ---------------------------------------------------------------------- > > -- > >=20 > ---------------------------------------------------------------------- > > -- > >=20 > ---------------------------------------------------------------------- > > -- > >=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) > > (actual time=3D427770.504..427771.894 rows=3D1000 loops=3D1) > > Sort Key: eventtime, sequencenum > > -> Seq Scan on eventlog (cost=3D0.00..2334535.17 > > rows=3D14031998 > > width=3D327) (actual time=3D10.370..190038.764 rows=3D7699388 = loops=3D1) > > Filter: ((eventtime > '2006-07-23 > 16:00:00'::timestamp > > without time zone) AND (eventtime < '2006-08-22 > 16:00:00'::timestamp > > 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) >=20 > If you analyze the table then run this again what plan does it come=20 > back with? >=20 > I can't read explain output properly but I suspect (and I'm sure I'll=20 > 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. >=20 > Do you have an index on objdomainid, objid and userdomainid (one index > per field) ? I wonder if that will help much. >=20 > -- > Postgresql & php tutorials > http://www.designmagick.com/ >=20 > ---------------------------(end of > broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? >=20 > http://www.postgresql.org/docs/faq >=20