X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 11693D1D838 for ; Wed, 19 Nov 2003 13:44:30 +0000 (GMT) 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 77963-07 for ; Wed, 19 Nov 2003 09:44:01 -0400 (AST) Received: from facnd.com (unknown [66.173.100.50]) by svr1.postgresql.org (Postfix) with ESMTP id E6664D1D85C for ; Wed, 19 Nov 2003 09:43:57 -0400 (AST) Received: by facnd.com (Postfix on SuSE Linux 7.3 (i386), from userid 553) id 04E07FC7; Wed, 19 Nov 2003 07:44:09 -0600 (CST) Received: from rob (unknown [192.1.1.100]) by facnd.com (Postfix on SuSE Linux 7.3 (i386)) with ESMTP id CC7DAFD8 for ; Wed, 19 Nov 2003 07:44:08 -0600 (CST) Reply-To: From: "Rob Sell" To: Subject: Re: Optimizing query Date: Wed, 19 Nov 2003 07:44:06 -0600 Organization: Fargo Assembly Company Message-ID: <003201c3aea3$33cc38b0$640101c0@rob> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 In-Reply-To: <3FBB60BE.4010407@myrealbox.com> Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/990 X-Sequence-Number: 52640 Greetings all,=20 Yesterday I upgraded from 7.3 to 7.4 now psql doesn't work! I get the following error.=20 psql: relocation error: psql: undefined symbol: get_progname=20 Any ideas out there? Rob -----Original Message----- From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Shridhar Daithankar Sent: Wednesday, November 19, 2003 6:23 AM To: Uros Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Optimizing query Uros wrote: > Hello! >=20 > I have some trouble getting good results from my query. >=20 > here is structure >=20 > stat_views > id | integer > id_zone | integer > created | timestamp >=20 >=20 > I have btree index on created and also id and there is 1633832 records in > that table >=20 > First of all I have to manualy set seq_scan to OFF because I always get > seq_scan. When i set it to off my explain show: >=20 > explain SELECT count(*) as views FROM stat_views WHERE id =3D 12; > QUERY PLAN > ---------------------------------------------------------------------------- ------------------------ > Aggregate (cost=3D122734.86..122734.86 rows=3D1 width=3D0) > -> Index Scan using stat_views_id_idx on stat_views (cost=3D0.00..122632.60 rows=3D40904 width=3D0) > Index Cond: (id =3D 12) >=20 > But what I need is to count views for some day, so I use >=20 > explain SELECT count(*) as views FROM stat_views WHERE date_part('day', created) =3D 18; >=20 > QUERY PLAN > ---------------------------------------------------------------------------- -------- > Aggregate (cost=3D100101618.08..100101618.08 rows=3D1 width=3D0) > -> Seq Scan on stat_views (cost=3D100000000.00..100101565.62 rows=3D= 20984 width=3D0) > Filter: (date_part('day'::text, created) =3D 18::double precisio= n) >=20 >=20 > How can I make this to use index and speed the query. Now it takes about 12 > seconds. Can you post explain analyze for the same? Shridhar ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster