Re: [PERFORM] fast DISTINCT or EXIST

2007-04-07 Thread Arjen van der Meijden
Can't you use something like this? Or is the distinct on the t.cd_id still causing the major slowdown here? SELECT ... FROM cd JOIN tracks ... WHERE cd.id IN (SELECT DISTINCT t.cd_id FROM tracks t WHERE t.tstitle @@ plainto_tsquery('simple','education') LIMIT 10) If that is your main

Re: [PERFORM] fast DISTINCT or EXIST

2007-04-07 Thread Tom Lane
Arjen van der Meijden [EMAIL PROTECTED] writes: If that is your main culprit, you could also use two limits based on the fact that there will be at most X songs per cd which would match your title (my not very educated guess is 3x). Its a bit ugly... but if that is what it takes to make

Re: [PERFORM] fast DISTINCT or EXIST

2007-04-07 Thread Tilo Buschmann
Hi everyone, On Sat, 07 Apr 2007 11:54:08 -0400 Tom Lane [EMAIL PROTECTED] wrote: Arjen van der Meijden [EMAIL PROTECTED] writes: If that is your main culprit, you could also use two limits based on the fact that there will be at most X songs per cd which would match your title (my not

Re: [PERFORM] fast DISTINCT or EXIST

2007-04-07 Thread Tom Lane
Tilo Buschmann [EMAIL PROTECTED] writes: Arjen van der Meijden [EMAIL PROTECTED] writes: SELECT ... FROM cd JOIN tracks ... WHERE cd.id IN (SELECT DISTINCT cd_id FROM (SELECT t.cd_id FROM tracks t WHERE t.tstitle @@ plainto_tsquery('simple','education') LIMIT 30) as foo LIMIT 10)

Re: [PERFORM] fast DISTINCT or EXIST

2007-04-07 Thread Arjen van der Meijden
On 7-4-2007 18:24 Tilo Buschmann wrote: Unfortunately, the query above will definitely not work correctly, if someone searches for a or the. That are two words you may want to consider not searching on at all. As Tom said, its not very likely to be fixed in PostgreSQL. But you can always