From: Andy Colson <andy@squeakycode.net>
To: sverhagen <sverhagen@wps-nl.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Performance trouble finding records through related records
Date: Thu, 03 Mar 2011 08:55:45 -0600
Message-ID: <4D6FABF1.50206@squeakycode.net> (raw)
In-Reply-To: <1299143960277-3407689.post@n5.nabble.com>
References: <1299024855300-3405914.post@n5.nabble.com>
<4D6DBC63.7080109@squeakycode.net>
<1299111156142-3407330.post@n5.nabble.com>
<4D6F054A.2090208@squeakycode.net>
<1299143960277-3407689.post@n5.nabble.com>
On 3/3/2011 3:19 AM, sverhagen wrote:
>
> Andy Colson wrote:
>>
>> For your query, I think a join would be the best bet, can we see its
>> explain analyze?
>>
>
>
> Here is a few variations:
>
>
> SELECT events_events.* FROM events_events WHERE transactionid IN (
> SELECT transactionid FROM events_eventdetails customerDetails
> WHERE customerDetails.keyname='customer_id'
> AND substring(customerDetails.value,0,32)='1957'
> AND transactionid IS NOT NULL
> ) ORDER BY id LIMIT 50;
>
> -- http://explain.depesz.com/s/Pnb
>
>
> explain analyze SELECT events_events.* FROM events_events,
> events_eventdetails customerDetails
> WHERE events_events.transactionid = customerDetails.transactionid
> AND customerDetails.keyname='customer_id'
> AND substring(customerDetails.value,0,32)='1957'
> AND customerDetails.transactionid IS NOT NULL
> ORDER BY id LIMIT 50;
>
> -- http://explain.depesz.com/s/rDh
>
>
> explain analyze SELECT events_events.* FROM events_events
> JOIN events_eventdetails customerDetails
> ON events_events.transactionid = customerDetails.transactionid
> AND customerDetails.keyname='customer_id'
> AND substring(customerDetails.value,0,32)='1957'
> AND customerDetails.transactionid IS NOT NULL
> ORDER BY id LIMIT 50;
>
> -- http://explain.depesz.com/s/6aB
>
>
> Thanks for your efforts!
>
Huh. Pretty much exactly the same. I'm sorry but I think I'm at my
limit. I'm not sure why the nested loop takes so long, or how to get it
to use something different.
-Andy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: andy@squeakycode.net, sverhagen@wps-nl.com
Subject: Re: Performance trouble finding records through related records
In-Reply-To: <4D6FABF1.50206@squeakycode.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox