agora inbox for pgsql-general@postgresql.org  
help / color / mirror / Atom feed
From: Rob Sell <lists@facnd.com>
To: pgsql-general@postgresql.org
Subject: Re: Optimizing query
Date: Wed, 19 Nov 2003 07:44:06 -0600
Message-ID: <003201c3aea3$33cc38b0$640101c0@rob> (raw)
In-Reply-To: <3FBB60BE.4010407@myrealbox.com>

Greetings all, 

Yesterday I upgraded from 7.3 to 7.4 now psql doesn't work! I get the
following error. 

psql: relocation error: psql: undefined symbol: get_progname 

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!
> 
> I have some trouble getting good results from my query.
> 
> here is structure
> 
> stat_views
> id        | integer
> id_zone   | integer
> created   | timestamp
> 
> 
> I have btree index on created and also id and there is  1633832 records in
> that table
> 
> 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:
> 
> explain SELECT count(*) as views FROM stat_views WHERE id = 12;
>                                              QUERY PLAN
>
----------------------------------------------------------------------------
------------------------
>  Aggregate  (cost=122734.86..122734.86 rows=1 width=0)
>    ->  Index Scan using stat_views_id_idx on stat_views
(cost=0.00..122632.60 rows=40904 width=0)
>          Index Cond: (id = 12)
> 
> But what I need is to count views for some day, so I use
> 
> explain SELECT count(*) as views FROM stat_views WHERE date_part('day',
created) = 18;
> 
>                                      QUERY PLAN
>
----------------------------------------------------------------------------
--------
>  Aggregate  (cost=100101618.08..100101618.08 rows=1 width=0)
>    ->  Seq Scan on stat_views  (cost=100000000.00..100101565.62 rows=20984
width=0)
>          Filter: (date_part('day'::text, created) = 18::double precision)
> 
> 
> 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




view thread (41+ messages)  latest in thread

Message-ID: <003201c3aea3$33cc38b0$640101c0@rob>
Permalink:  ../003201c3aea3$33cc38b0$640101c0@rob/
Also on:    postgresql.org/message-id/003201c3aea3$33cc38b0$640101c0@rob

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-general@postgresql.org
  Cc: lists@facnd.com
  Subject: Re: Optimizing query
  In-Reply-To: <003201c3aea3$33cc38b0$640101c0@rob>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox