Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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 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    work: 512-231-6117
vcard:       cell: 512-569-9461

In response to


pgsql-performance by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group