Re: best way to query

From: Steve Clark <sclark(at)netwolves(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: best way to query
Date: 2008-01-25 17:19:18
Message-ID: 479A1A16.9090406@netwolves.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> Steve Clark <sclark(at)netwolves(dot)com> writes:
>
>>Tom Lane wrote:
>>
>>>Also, whatever is the ORDER BY for?
>
>
>>without the order by it wants to do a seq scan of t_unit_event_log.
>>see below:
>> explain select count(*) from t_event_ack_log where event_log_no not
>>in (select event_log_no from t_unit_event_log);
>> QUERY PLAN
>>----------------------------------------------------------------------------------------
>> Aggregate (cost=12144872193.82..12144872193.82 rows=1 width=0)
>> -> Seq Scan on t_event_ack_log (cost=0.00..12144871485.07
>>rows=283497 width=0)
>> Filter: (NOT (subplan))
>> SubPlan
>> -> Seq Scan on t_unit_event_log (cost=0.00..40286.56
>>rows=1021156 width=4)
>>(5 rows)
>
>
> Hmm, the big problem with that isn't the seqscan but the lack of a
> Materialize step to buffer it; which says to me that you're running a
> pretty old Postgres version (8.0 or older). You should think about an
> update if you're running into performance issues.
>
> regards, tom lane
>
>

Hi Tom,

Actually this is

show server_version;
server_version
----------------
8.2.5

On FreeBSD 6.2

And Daniel gave me a query that does the job in just a few seconds.

Thanks,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Geoffrey 2008-01-25 19:34:36 what is it that \d actually does
Previous Message Steve Clark 2008-01-25 17:15:43 Re: best way to query