Re: [PERFORM] index not being used when variable is sent

2011-08-17 Thread Jim Nasby
On Aug 17, 2011, at 1:49 AM, Eyal Wilde wrote: > 1. is there any more elegant solution? Very possibly, but I'm having a heck of a time trying to figure out what your current code is actually doing. What's the actual problem you're trying to solve here? -- Jim C. Nasby, Database Architect

Re: [PERFORM] index not being used when variable is sent

2011-08-17 Thread Eyal Wilde
Thanks for the reply. (i'm sorry for that i didn't really know how to reply to a certain message...) well, i used LIKE, but i actually wanted just "starts with". the solution i found without using LIKE is this: CREATE OR REPLACE FUNCTION test_func(STR text) RETURNS integer AS $BODY$ declare ST

Re: [PERFORM] index not being used when variable is sent

2011-08-16 Thread Tom Lane
Eyal Wilde writes: > CREATE OR REPLACE FUNCTION test_func(STR text) > ... > perform t1.val FROM t1 WHERE > (COALESCE(rpad(t1.val, 100),'') ) like COALESCE(STR || '%','') > order by COALESCE(rpad(t1.val, 100), '') using ~<~ LIMIT 5; [ doesn't use index ] No, it doesn't. The LIKE index optimizati

[PERFORM] index not being used when variable is sent

2011-08-16 Thread Eyal Wilde
Hi, I encountered a problem while trying to improve the performance of a certain select query I have made. here is a simplified code for the function I am using CREATE OR REPLACE FUNCTION test_func(STR text) RETURNS integer AS $BODY$ begin insert into plcbug(val) values('begin time before perfor