Re: Speeding up query, Joining 55mil and 43mil records. - Mailing list pgsql-performance

From Jim C. Nasby
Subject Re: Speeding up query, Joining 55mil and 43mil records.
Date
Msg-id 20060621184803.GC93655@pervasive.com
Whole thread Raw
In response to Speeding up query, Joining 55mil and 43mil records.  (nicky <nicky@valuecare.nl>)
Responses Re: Speeding up query, Joining 55mil and 43mil records.  (nicky <nicky@valuecare.nl>)
List 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@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

pgsql-performance by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: Big array speed issues
Next
From: "Jim C. Nasby"
Date:
Subject: Re: Help tuning autovacuum - seeing lots of relation bloat