Re: [GENERAL] Poor Performance with Distinct Subqueries with EXISTS and EXCEPT

2004-12-03 Thread Thomas F . O'Connell
Interestingly, I tried the new version with and without enable_seqscan on, and the version without indexes performs better because, I think, it returns more rows than an index lookup would enhance. Thanks again for your help. This is certainly an improvement over my original version. -tfo -- T

Re: [GENERAL] Poor Performance with Distinct Subqueries with EXISTS and EXCEPT

2004-12-03 Thread Thomas F . O'Connell
Pierre, Your re-write makes a lot of sense. Thanks! It's not using indexes for some reason, and discovering why will be my next challenge. -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 6

Re: [GENERAL] Poor Performance with Distinct Subqueries with EXISTS and EXCEPT

2004-12-02 Thread Thomas F . O'Connell
I wasn't sure whether EXCEPT would create a unique set from among the results of both queries. As in, if the first part of the query (before the EXCEPT clause), without the DISTINCT, yielded yahoo.com yahoo.com would the query reduce that to a single yahoo.com regardless of whether it showed u

Re: [GENERAL] Poor Performance with Distinct Subqueries with EXISTS and EXCEPT

2004-12-02 Thread Tom Lane
=?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= <[EMAIL PROTECTED]> writes: > I may be mistaken, but you may be doing the same thing twice : you're > basically writing : > SELECT DISTINCT X WHERE Y EXCEPT SELECT DISTINCT X WHERE NOT Y > Is this not a way to get an empty result s

Re: [GENERAL] Poor Performance with Distinct Subqueries with EXISTS and EXCEPT

2004-12-02 Thread Pierre-Frédéric Caillaud
Now, since I'm actually interested in unique domain names rather than unique users, I need to get all the unique domain names corresponding to users who have acted on a message. That's what the part of the query after the EXCEPT is. I don't understand this part at all. What does it mean ?

[GENERAL] Poor Performance with Distinct Subqueries with EXISTS and EXCEPT

2004-12-01 Thread Thomas F . O'Connell
I'm trying to do some research and reporting for an email application by domain name. This has led to a confounding attempt to do any of the legwork in SQL via postgres. Here is my foundational query: SELECT DISTINCT split_part( u.email, '@', 2 ) FROM user AS u, message AS m WHERE u.id = m.use