Re: Slow queries in PL/PGSQL function

From: Gary Doades <gpd(at)cwcom(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Slow queries in PL/PGSQL function
Date: 2004-02-22 10:36:47
Message-ID: c91h301icsol2kqbbm4fs1hrv3opcdkgrv@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

It's OK, I'm an idiot.

I read soooo many times that you need to get the data types in the query the same as the column
types or indexes won't work. So I go and get it wrong!

I had defined the parameter to the function as timestamp (equivalent to SQLServer datetime), but the
column data type is date. SQLServer does not have a date type so the datetime parameters work, but
straight conversion causes PG not to use indexes.

I guess that many might be put off PG because of this without bothering to find out why. I think I
read somewhere that there are plans to improve PGs behaviour in this area, is this so?

Cheers,
Gary.

On Sat, 21 Feb 2004 11:15:50 -0500, tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane) wrote:

>Gary Doades <gpd(at)cwcom(dot)net> writes:
>> Is there someway to force the use of an index. Or at least get the
>> backend to substitue the parameters in a function before doing the
>> first query plan so it has more typical values to work with?
>
>Could we see the EXPLAIN ANALYZE output for your problem query?
>Table schemas (column data types and available indexes) are necessary
>background for this type of question as well.
>
>You might want to take the question to pgsql-performance, too ...
>it's a tad off topic for -general.
>
> regards, tom lane
>
>---------------------------(end of broadcast)---------------------------
>TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Birzan George Cristian 2004-02-22 11:19:01 phpBB 2.2 and PostgreSQL support
Previous Message Bas Scheffers 2004-02-22 10:09:41 Re: Binary data in PostgreSQL