pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: sverhagen <sverhagen@wps-nl.com>
To: pgsql-performance@postgresql.org
Subject: Re: Performance trouble finding records through related records
Date: Thu, 3 Mar 2011 01:19:20 -0800 (PST)
Message-ID: <1299143960277-3407689.post@n5.nabble.com> (raw)
In-Reply-To: <4D6F054A.2090208@squeakycode.net>
References: <1299024855300-3405914.post@n5.nabble.com>
	<4D6DBC63.7080109@squeakycode.net>
	<1299111156142-3407330.post@n5.nabble.com>
	<4D6F054A.2090208@squeakycode.net>


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!

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Performance-trouble-finding-records-through-related-records-...
Sent from the PostgreSQL - performance mailing list archive at Nabble.com.



view thread (11+ messages)  latest in thread

Message-ID: <1299143960277-3407689.post@n5.nabble.com>
Permalink:  ../1299143960277-3407689.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1299143960277-3407689.post@n5.nabble.com

 · 

reply

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: sverhagen@wps-nl.com
  Subject: Re: Performance trouble finding records through related records
  In-Reply-To: <1299143960277-3407689.post@n5.nabble.com>

* 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