Re: Speeding up query, Joining 55mil and 43mil records.

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: nicky <nicky(at)valuecare(dot)nl>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Speeding up query, Joining 55mil and 43mil records.
Date: 2006-06-21 18:48:03
Message-ID: 20060621184803.GC93655@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, Jun 21, 2006 at 03:47:19PM +0200, nicky wrote:
> WHERE substr(t0.code,1,2) not in ('14','15','16','17')
> AND (substr(t0.correctie,4,1) <> '1' OR t0.correctie is null)
> AND EXTRACT(YEAR from t1.datum) > 2004;

How much data do you expect to be getting back from that where clause?
Unless you plan on inserting most of the table, some well-placed indexes
would probably help, and fixing the datum portion might as well
(depending on how far back the data goes). Specifically:

CREATE INDEX t0_code_partial ON t0(substr(code,1,2));
(yeah, I know t0 is an alias, but I already snipped the table name)

and

AND t1.datum >= '1/1/2005'

(might need to cast that to a date or whatever).
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Jim C. Nasby 2006-06-21 18:57:53 Re: Help tuning autovacuum - seeing lots of relation bloat
Previous Message Jim C. Nasby 2006-06-21 18:33:05 Re: Big array speed issues