From: | Rory Campbell-Lange <rory(at)campbell-lange(dot)net> |
---|---|
To: | Nick Barr <nicky(at)chuckie(dot)co(dot)uk> |
Cc: | "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>, Paul Thomas <paul(at)tmsl(dot)demon(dot)co(dot)uk> |
Subject: | Re: Very slow query |
Date: | 2004-05-11 10:05:26 |
Message-ID: | 20040511100525.GB30000@campbell-lange.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 11/05/04, Nick Barr (nicky(at)chuckie(dot)co(dot)uk) wrote:
> Rory Campbell-Lange wrote:
> > > Look carefully at your column types. I can see several smallint
> > > columns in there WHERE clause which are not expicitely typed as
> > > such.
> > I'm not sure how to do this, Paul. do I do b.n_id::smallint ? Is
> > smallint not implied?
> Not quite. Explicit casts are needed when you have any numbers in the
> WHERE condition and the columns are not of type integer/int4. For
> example I have tweaked your query.
...
> Note that b.n_creator and o.n_creator do not need explicit casts because
> they are both of type integer anyway. You could of course put them in
> for clarity. PG only casts the numbers to integer's, and not to smallint
> or bigint, which basically means it does not use any indexes on that
> column. This is fixed in 7.4 I believe, which you seem to be running
> anyway so you might not be affected.
Mmm. Seems like I should try profiling with and without the cast. Maybe
there is little value in defining a column as a smallint, other than
checking the length of input.
Thanks again for your help,
Rory
--
Rory Campbell-Lange
<rory(at)campbell-lange(dot)net>
<www.campbell-lange.net>
From | Date | Subject | |
---|---|---|---|
Next Message | Reynir Þór Hübner | 2004-05-11 10:36:35 | JDBC problem |
Previous Message | Nick Barr | 2004-05-11 09:50:34 | Re: Very slow query |