Re: [PERFORM] Performance penalty when using WITH

2011-08-04 Thread Li Jin
Robert, I've built an index on this expression firstname || ' ' || substring(lastname,1,1). I believe this is the best index for this particular query. Correct me if I am wrong. Li On Aug 3, 2011, at 3:18 AM, Robert Klemme wrote: > On Tue, Aug 2, 2011 at 11:48 PM, Merlin Moncure wrote: >> On

Re: [PERFORM] Performance penalty when using WITH

2011-08-03 Thread Robert Klemme
On Wed, Aug 3, 2011 at 6:24 PM, Merlin Moncure wrote: > On Wed, Aug 3, 2011 at 2:18 AM, Robert Klemme > wrote: Another observation: That criterion looks suspicious to me. I would expect any RDBMS to be better able to optimize this: WHERE firstname = 'Eddie' AND lastname like '

Re: [PERFORM] Performance penalty when using WITH

2011-08-03 Thread Robert Klemme
On Wed, Aug 3, 2011 at 3:27 PM, Li Jin wrote: > Robert, > I've built an index on this expression firstname || ' ' || > substring(lastname,1,1). I believe this is the best index for this > particular query. Correct me if I am wrong. Maybe, maybe not. Difficult to tell from a distance. I would ha

Re: [PERFORM] Performance penalty when using WITH

2011-08-03 Thread Merlin Moncure
On Wed, Aug 3, 2011 at 2:18 AM, Robert Klemme wrote: >>> Another observation: That criterion looks suspicious to me. I would >>> expect any RDBMS to be better able to optimize this: >>> >>> WHERE firstname = 'Eddie' AND lastname like 'T%' >>> >>> I know it's semantically not the same but I would a

Re: [PERFORM] Performance penalty when using WITH

2011-08-03 Thread Robert Klemme
On Wed, Aug 3, 2011 at 3:27 PM, Li Jin wrote: > Robert, > I've built an index on this expression firstname || ' ' || > substring(lastname,1,1). I believe this is the best index for this > particular query. Correct me if I am wrong. Maybe, maybe not. Difficult to tell from a distance. I would ha

Re: [PERFORM] Performance penalty when using WITH

2011-08-03 Thread Robert Klemme
On Tue, Aug 2, 2011 at 11:48 PM, Merlin Moncure wrote: > On Sat, Jul 30, 2011 at 8:10 AM, Robert Klemme > wrote: >> On Thu, Jul 28, 2011 at 11:00 PM, Li Jin wrote: >>> I met with the problem that when I was using WITH clause to reuse a >>> subquery, I got a huge performance penalty because of qu

Re: [PERFORM] Performance penalty when using WITH

2011-08-02 Thread Merlin Moncure
On Sat, Jul 30, 2011 at 8:10 AM, Robert Klemme wrote: > On Thu, Jul 28, 2011 at 11:00 PM, Li Jin wrote: >> I met with the problem that when I was using WITH clause to reuse a >> subquery, I got a huge performance penalty because of query planner. >> Here are the details, the original query is >>

Re: [PERFORM] Performance penalty when using WITH

2011-07-30 Thread Robert Klemme
On Thu, Jul 28, 2011 at 11:00 PM, Li Jin wrote: > I met with the problem that when I was using WITH clause to reuse a > subquery, I got a huge performance penalty because of query planner. > Here are the details, the original query is > EXPLAIN ANALYZE WITH latest_identities AS > ( >     SELECT DI

Re: [PERFORM] Performance penalty when using WITH

2011-07-29 Thread Tom Lane
Li Jin writes: > Anyone knows why the planner is doing this? WITH is an optimization fence. This is intentional and documented. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://

[PERFORM] Performance penalty when using WITH

2011-07-29 Thread Li Jin
Hi guys, I met with the problem that when I was using WITH clause to reuse a subquery, I got a huge performance penalty because of query planner. Here are the details, the original query is EXPLAIN ANALYZE WITH latest_identities AS ( SELECT DISTINCT ON (memberid) memberid, username, change