Re: [SQL] could not find pathkey item to sort

2006-12-07 Thread Tom Lane
"Phillip Smith" <[EMAIL PROTECTED]> writes: > Since upgrading to PG 8.2, I'm getting this error on a nightly (bash) > script > ERROR: could not find pathkey item to sort I think this is a variant manifestation of the same bug already reported here: http://archives.postgresql.org/pgsql-hackers/2006

Re: [SQL] Query is fast and function is slow

2006-12-07 Thread Tom Lane
Richard Ray <[EMAIL PROTECTED]> writes: > Changing both parameters to char(9) and name fixed the problem > It appears to be using the index > If time allows could you explain this a bit EXPLAIN will show you what's going on: regression=# create table foo (f1 char(9) unique); NOTICE: CREATE TABLE

[SQL] could not find pathkey item to sort

2006-12-07 Thread Phillip Smith
Hi All, Since upgrading to PG 8.2, I'm getting this error on a nightly (bash) script that calls psql (it's purpose is to find stock codes that share an EAN Barcode with another code - it used to work, now doesn't): ERROR: could not find pathkey item to sort SQL state: XX000 The error is b

Re: [SQL] Query is fast and function is slow

2006-12-07 Thread Richard Ray
On Thu, 7 Dec 2006, Tom Lane wrote: Richard Ray <[EMAIL PROTECTED]> writes: On Thu, 7 Dec 2006, Thomas Pundt wrote: Just a guess: is the column "doc_num" really of type text? Maybe using "text" in the function lets the planner choose a sequential scan? Actually "doc_num" is char(9) I change

Re: [SQL] Query is fast and function is slow

2006-12-07 Thread Tom Lane
Richard Ray <[EMAIL PROTECTED]> writes: > On Thu, 7 Dec 2006, Thomas Pundt wrote: >> Just a guess: is the column "doc_num" really of type text? Maybe using "text" >> in the function lets the planner choose a sequential scan? > Actually "doc_num" is char(9) > I changed text to char(9) and got same

Re: [SQL] Query is fast and function is slow

2006-12-07 Thread Thomas Pundt
Hi, On Thursday 07 December 2006 15:53, Richard Ray wrote: | But this same statement in a function takes several minutes; | | My SQL knowledge is pitiful so would you explain how to use | "explain analyze" in the function | | I get errors when I try to load the file with | raise notice ''%'',expl

Re: [SQL] Query is fast and function is slow

2006-12-07 Thread Richard Ray
On Thu, 7 Dec 2006, Thomas Pundt wrote: Hi, On Wednesday 06 December 2006 16:44, Richard Ray wrote: | select count(*) from documents where doc_num = '106973821' and (select | bit_or(group_access) from mda_groups where group_name in (select groname | from pg_user,pg_group where usename = 'bbob

Re: [SQL] Query is fast and function is slow

2006-12-07 Thread Thomas Pundt
Hi, On Wednesday 06 December 2006 16:44, Richard Ray wrote: | select count(*) from documents where doc_num = '106973821' and (select | bit_or(group_access) from mda_groups where group_name in (select groname | from pg_user,pg_group where usename = 'bbob' and usesysid = any(grolist) | and (grona