Re: [PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-10 Thread Richard Yen
On Dec 9, 2008, at 3:27 PM, Tom Lane wrote: Richard Yen [EMAIL PROTECTED] writes: I've discovered a peculiarity with using btrim in an index and was wondering if anyone has any input. What PG version is this? This is running on 8.3.3 In particular, I'm wondering if it's one of the early

Re: [PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-10 Thread Tom Lane
Richard Yen [EMAIL PROTECTED] writes: You guys are right. I tried Miller and gave me the same result. Is there any way to tune this so that for the common last names, the query run time doesn't jump from 1s to 300s? If the planner's estimation is that far off then there must be something

Re: [PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-10 Thread Robert Haas
You guys are right. I tried Miller and gave me the same result. Is there any way to tune this so that for the common last names, the query run time doesn't jump from 1s to 300s? Thanks for the help! Can you send the output of EXPLAIN ANALYZE for both cases? ...Robert -- Sent via

Re: [PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-10 Thread Tom Lane
BTW, if your queries typically constrain both lastname and firstname, it'd likely be worthwhile to make a 2-column index on lower(btrim(x_lastname)), lower(btrim(x_firstname)) regards, tom lane -- Sent via pgsql-performance mailing list

Re: [PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-10 Thread Richard Yen
On Dec 10, 2008, at 11:34 AM, Tom Lane wrote: Richard Yen [EMAIL PROTECTED] writes: You guys are right. I tried Miller and gave me the same result. Is there any way to tune this so that for the common last names, the query run time doesn't jump from 1s to 300s? If the planner's

Re: [PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-10 Thread Richard Yen
On Dec 10, 2008, at 11:39 AM, Robert Haas wrote: You guys are right. I tried Miller and gave me the same result. Is there any way to tune this so that for the common last names, the query run time doesn't jump from 1s to 300s? Thanks for the help! Can you send the output of EXPLAIN

Re: [PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-10 Thread Vladimir Sitnikov
tii=# explain analyze SELECT m_object_paper.id FROM m_object_paper, m_assignment WHERE m_object_paper.assignment = m_assignment.id AND m_object_paper.owner=-1 AND m_assignment.class = 2450798 AND lower(btrim(x_firstname)) = lower(btrim('Jordan')) and lower(btrim(x_lastname)) =

Re: [PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-10 Thread Tom Lane
Richard Yen [EMAIL PROTECTED] writes: Is there any way to tune this so that for the common last names, the query run time doesn't jump from 1s to 300s? Well, as near as I can tell there's factor of a couple hundred difference between the frequencies of 'smith' and 'smithers', so you shouldn't

Re: [PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-10 Thread Richard Yen
On Dec 10, 2008, at 4:08 PM, Tom Lane wrote: Richard Yen [EMAIL PROTECTED] writes: Is there any way to tune this so that for the common last names, the query run time doesn't jump from 1s to 300s? Well, as near as I can tell there's factor of a couple hundred difference between the

[PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-09 Thread Richard Yen
Hi, I've discovered a peculiarity with using btrim in an index and was wondering if anyone has any input. My table is like this: Table public.m_object_paper Column| Type | Modifiers

Re: [PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-09 Thread David Wilson
On Tue, Dec 9, 2008 at 2:56 PM, Richard Yen [EMAIL PROTECTED] wrote: In practice, the difference is 300+ seconds when $LASTNAME == 5 chars and 1 second when $LASTNAME != 5 chars. Would anyone know what's going on here? Is there something about the way btrim works, or perhaps with the way

Re: [PERFORM] query plan with index having a btrim is different for strings of different length

2008-12-09 Thread Tom Lane
Richard Yen [EMAIL PROTECTED] writes: I've discovered a peculiarity with using btrim in an index and was wondering if anyone has any input. What PG version is this? In particular, I'm wondering if it's one of the early 8.2.x releases, which had some bugs in and around choose_bitmap_and()